Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-3690

add new validation rule for 'money' formats that can be negative

    Details

    • Type: New Feature
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.1
    • Fix Version/s: 3.1
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      Create a new validation rule similar to CRM/Utils/Rule.php::money() except that it would allow both positive and negative money values.

      The current money function uses preg_match against
      '/(\d+\.\d?\d?$)|(\.\d\d?$)/'

      A new function (eg. 'moneyposneg' or 'moneysigned') could use preg_match
      '/(?\d+\.\d?\d?$)|(?\.\d\d?$)/'

      With this new validation rule, it would allow a selection of custom field type to be 'money - positive' or 'money - signed', each with their corresponding validation rule.

      There is not a use case for this in any of the built-in money fields in CiviCRM, but I ran into this limitation when I wanted to add a custom field for a rebate amount.

        Attachments

          Activity

            People

            • Assignee:
              rahulbile Rahul Bile
              Reporter:
              chrism Chris Mott
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: