commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r232646 - in /jakarta/commons/proper/validator/trunk/src: share/org/apache/commons/validator/CreditCardValidator.java test/org/apache/commons/validator/CreditCardValidatorTest.java
Date Sun, 14 Aug 2005 21:19:42 GMT
Author: mrdon
Date: Sun Aug 14 14:19:39 2005
New Revision: 232646

URL: http://svn.apache.org/viewcvs?rev=232646&view=rev
Log:
Adding support for the Visa Carte Blue used in France to the credit card validator
PR: 35926

Modified:
    jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/CreditCardValidator.java
    jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/CreditCardValidatorTest.java

Modified: jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/CreditCardValidator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/CreditCardValidator.java?rev=232646&r1=232645&r2=232646&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/CreditCardValidator.java
(original)
+++ jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/CreditCardValidator.java
Sun Aug 14 14:19:39 2005
@@ -205,15 +205,19 @@
         
     }
     
+    /**
+     *  Augmented to support Visa Carte Blue used in France
+     */
     private class Visa implements CreditCardType {
-        private static final String PREFIX = "4";
+        private static final String PREFIX = "4,5,";
         public boolean matches(String card) {
-            return (
-                card.substring(0, 1).equals(PREFIX)
-                    && (card.length() == 13 || card.length() == 16));
+            
+        String prefix2 = card.substring(0, 1) + ",";
+        return ((PREFIX.indexOf(prefix2) != -1)
+            && (card.length() == 13 || card.length() == 16));
         }
-    }
-    
+    }    
+            
     private class Amex implements CreditCardType {
         private static final String PREFIX = "34,37,";
         public boolean matches(String card) {

Modified: jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/CreditCardValidatorTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/CreditCardValidatorTest.java?rev=232646&r1=232645&r2=232646&view=diff
==============================================================================
--- jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/CreditCardValidatorTest.java
(original)
+++ jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/CreditCardValidatorTest.java
Sun Aug 14 14:19:39 2005
@@ -29,6 +29,7 @@
 public class CreditCardValidatorTest extends TestCase {
     
     private static final String VALID_VISA = "4417123456789113";
+    private static final String VALID_VISA_OTHER = "5817550003933609";
     private static final String VALID_SHORT_VISA = "4222222222222";
     private static final String VALID_AMEX = "378282246310005";
     private static final String VALID_MASTERCARD = "5105105105105100";
@@ -52,6 +53,7 @@
         assertFalse(ccv.isValid("4417123456789112"));
         assertFalse(ccv.isValid("4417q23456w89113"));
         assertTrue(ccv.isValid(VALID_VISA));
+        assertTrue(ccv.isValid(VALID_VISA_OTHER));
         assertTrue(ccv.isValid(VALID_SHORT_VISA));
         assertTrue(ccv.isValid(VALID_AMEX));
         assertTrue(ccv.isValid(VALID_MASTERCARD));



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message