Commons Validator
  1. Commons Validator
  2. VALIDATOR-39

[validator] CreditValidator does not handle Visa correctly

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      When using 5817550003933609 as card number the check will fail. This number is
      a valid Visa number, as used for Visa Carte Blue in France.

      Solution:
      change the Visa inner class to:

      private class Visa implements CreditCardType {
      private static final String PREFIX = "4,5,";
      public boolean matches(String card)

      { String prefix2 = card.substring(0, 1) + ","; return ((PREFIX.indexOf(prefix2) != -1) && (card.length() == 13 || card.length() == 16)); }

      }

        Activity

        Leo Moot created issue -
        Hide
        Don Brown added a comment -

        Fixed in changeset [232646]. Thanks for the patch!

        Show
        Don Brown added a comment - Fixed in changeset [232646] . Thanks for the patch!
        Hide
        Christoph Kutzinski added a comment -

        I don't think that the patch is correct. It will match too many card numbers.
        Mastercard numbers start e.g. with 51 - 55. Therefore Visa.matches() will now
        return "true" for Mastercards, too.

        Show
        Christoph Kutzinski added a comment - I don't think that the patch is correct. It will match too many card numbers. Mastercard numbers start e.g. with 51 - 55. Therefore Visa.matches() will now return "true" for Mastercards, too.
        Hide
        Niall Pemberton added a comment -

        I agree with Christoph, this change renders the MasterCard check
        redundant/useless.

        Its hard to find an authoritative source defining the rules for credit card
        numbers - looks like you have to buy the standards from ISO or ANSI. The other
        validators I looked at only allow numbers starting with "4" for visa.

        Leo can you point to a reference which defines the card number format for Visa
        Carte Blue?

        At this point I'm for rolling back this change. The "Visa Carte Blue" situation
        can be resolved by creating a custom CreditCardType implementation and
        registering it using the addAllowedCardType(CreditCardType) method.

        I'll leave this for a couple of weeks, to allow people to respond. After that,
        unless convincing arguments are made, I'll revert this change.

        Show
        Niall Pemberton added a comment - I agree with Christoph, this change renders the MasterCard check redundant/useless. Its hard to find an authoritative source defining the rules for credit card numbers - looks like you have to buy the standards from ISO or ANSI. The other validators I looked at only allow numbers starting with "4" for visa. Leo can you point to a reference which defines the card number format for Visa Carte Blue? At this point I'm for rolling back this change. The "Visa Carte Blue" situation can be resolved by creating a custom CreditCardType implementation and registering it using the addAllowedCardType(CreditCardType) method. I'll leave this for a couple of weeks, to allow people to respond. After that, unless convincing arguments are made, I'll revert this change.
        Hide
        Niall Pemberton added a comment -

        I don't know if they're authoritative but the following sources both define
        visa as starting with "4"

        http://www.merriampark.com/anatomycc.htm#Issuer
        http://www.encyclopedian.com/cr/Credit-card.html#Credit-card-numbering

        Show
        Niall Pemberton added a comment - I don't know if they're authoritative but the following sources both define visa as starting with "4" http://www.merriampark.com/anatomycc.htm#Issuer http://www.encyclopedian.com/cr/Credit-card.html#Credit-card-numbering
        Hide
        Niall Pemberton added a comment -

        I have reversed this changed and so am closing this as "WONTFIX"

        http://svn.apache.org/viewcvs?rev=366867&view=rev

        Show
        Niall Pemberton added a comment - I have reversed this changed and so am closing this as "WONTFIX" http://svn.apache.org/viewcvs?rev=366867&view=rev
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 35926 12342416
        Henri Yandell made changes -
        Affects Version/s unspecified [ 12311647 ]
        Key COM-2264 VALIDATOR-39
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Component/s Validator [ 12311135 ]
        Project Commons [ 12310458 ] Commons Validator [ 12310494 ]
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

        Error rendering 'com.atlassian.jirafisheyeplugin:fisheye-issuepanel'. Please contact your JIRA administrators.

          People

          • Assignee:
            Unassigned
            Reporter:
            Leo Moot
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development