commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgra...@apache.org
Subject cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator CreditCardValidator.java GenericValidator.java
Date Thu, 01 May 2003 02:15:16 GMT
dgraham     2003/04/30 19:15:16

  Modified:    validator/src/share/org/apache/commons/validator
                        CreditCardValidator.java GenericValidator.java
  Log:
  Changed isCreditCard to standard isValid.
  
  Revision  Changes    Path
  1.4       +12 -13    jakarta-commons/validator/src/share/org/apache/commons/validator/CreditCardValidator.java
  
  Index: CreditCardValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/CreditCardValidator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CreditCardValidator.java	30 Apr 2003 22:11:06 -0000	1.3
  +++ CreditCardValidator.java	1 May 2003 02:15:16 -0000	1.4
  @@ -107,7 +107,7 @@
   	 *
   	 * @param value The value validation is being performed on.
   	 */
  -	public boolean isCreditCard(String value) {
  +	public boolean isValid(String value) {
   		return (
   			this.validateCreditCardLuhnCheck(value)
   				&& this.validateCreditCardPrefixCheck(value));
  @@ -162,14 +162,13 @@
   			return false;
   		}
   
  -		boolean valid = false;
   		int cardType = 0;
   
  -		String prefix2 = cardNumber.substring(0, 2) + ",";
  +		final String prefix2 = cardNumber.substring(0, 2) + ",";
   
   		if (AX_PREFIX.indexOf(prefix2) != -1) {
   			cardType = 3;
  -		}
  +		} 
   		if (cardNumber.substring(0, 1).equals(VS_PREFIX)) {
   			cardType = 4;
   		}
  @@ -181,19 +180,19 @@
   		}
   
   		if ((cardType == 3) && (length == 15)) {
  -			valid = true;
  +			return true;
   		}
   		if ((cardType == 4) && ((length == 13) || (length == 16))) {
  -			valid = true;
  +			return true;
   		}
   		if ((cardType == 5) && (length == 16)) {
  -			valid = true;
  +			return true;
   		}
   		if ((cardType == 6) && (length == 16)) {
  -			valid = true;
  +			return true;
   		}
   
  -		return valid;
  +		return false;
   	}
   
   }
  
  
  
  1.21      +5 -5      jakarta-commons/validator/src/share/org/apache/commons/validator/GenericValidator.java
  
  Index: GenericValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/GenericValidator.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- GenericValidator.java	30 Apr 2003 22:11:06 -0000	1.20
  +++ GenericValidator.java	1 May 2003 02:15:16 -0000	1.21
  @@ -300,7 +300,7 @@
       * @param value The value validation is being performed on.
       */
      public static boolean isCreditCard(String value) {
  -      return CreditCardValidator.getInstance().isCreditCard(value);
  +      return CreditCardValidator.getInstance().isValid(value);
      }
   
      /**
  
  
  

---------------------------------------------------------------------
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