Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-414

Simplify CreditCard validation

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Done
    • None
    • None
    • CreditCard
    • None

    Description

      It's tricky validating Credit card numbers using only regular expressions.

      It would be a lot simpler to check the syntax (digits only) and length, and then validate the IIN (initial 6 digits) separately using numeric ranges.

      No need even to convert the strings to numbers, because string comparison would work just as well.

      Unfortunately CreditCardValidator uses the final class CodeValidator in its public API, but the latter can accept a RegexValidator which can be subclassed to provide the necessary functionality. This should be possible without further exposing the internal workings.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sebb Sebb
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: