|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.validator.CreditCardValidator
public class CreditCardValidator
Perform credit card validations.
By default, all supported card types are allowed. You can specify which
cards should pass validation by configuring the validation options. For
example,CreditCardValidator ccv = new CreditCardValidator(CreditCardValidator.AMEX + CreditCardValidator.VISA);
configures the validator to only pass American Express and Visa cards.
If a card type is not directly supported by this class, you can implement
the CreditCardType interface and pass an instance into the
addAllowedCardType
method.
Nested Class Summary | |
---|---|
static interface |
CreditCardValidator.CreditCardType
Deprecated. CreditCardType implementations define how validation is performed for one type/brand of credit card. |
Field Summary | |
---|---|
static int |
AMEX
Deprecated. Option specifying that American Express cards are allowed. |
static int |
DISCOVER
Deprecated. Option specifying that Discover cards are allowed. |
static int |
MASTERCARD
Deprecated. Option specifying that Mastercard cards are allowed. |
static int |
NONE
Deprecated. Option specifying that no cards are allowed. |
static int |
VISA
Deprecated. Option specifying that Visa cards are allowed. |
Constructor Summary | |
---|---|
CreditCardValidator()
Deprecated. Create a new CreditCardValidator with default options. |
|
CreditCardValidator(int options)
Deprecated. Create a new CreditCardValidator with the specified options. |
Method Summary | |
---|---|
void |
addAllowedCardType(CreditCardValidator.CreditCardType type)
Deprecated. Add an allowed CreditCardType that participates in the card validation algorithm. |
boolean |
isValid(String card)
Deprecated. Checks if the field is a valid credit card number. |
protected boolean |
luhnCheck(String cardNumber)
Deprecated. Checks for a valid credit card number. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NONE
CreditCardValidator v = new CreditCardValidator(CreditCardValidator.NONE); v.addAllowedCardType(customType); v.isValid(aCardNumber);
public static final int AMEX
public static final int VISA
public static final int MASTERCARD
public static final int DISCOVER
Constructor Detail |
---|
public CreditCardValidator()
public CreditCardValidator(int options)
options
- Pass in
CreditCardValidator.VISA + CreditCardValidator.AMEX to specify that
those are the only valid card types.Method Detail |
---|
public boolean isValid(String card)
card
- The card number to validate.
public void addAllowedCardType(CreditCardValidator.CreditCardType type)
type
- The type that is now allowed to pass validation.protected boolean luhnCheck(String cardNumber)
cardNumber
- Credit Card Number.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |