public class CreditCardValidationRule extends BaseValidationRule
Validator
Modifier and Type | Field and Description |
---|---|
protected static String |
CREDIT_CARD_VALIDATOR_KEY
Key used to pull out encoder in configuration.
|
allowNull, encoder
Constructor and Description |
---|
CreditCardValidationRule(String typeName,
Encoder encoder)
Creates a CreditCardValidator using the rule found in security configuration
|
CreditCardValidationRule(String typeName,
Encoder encoder,
StringValidationRule validationRule) |
Modifier and Type | Method and Description |
---|---|
int |
getMaxCardLength() |
StringValidationRule |
getStringValidatorRule() |
String |
getValid(String context,
String input)
Parse the input, throw exceptions if validation fails
|
String |
sanitize(String context,
String input)
The method is similar to ValidationRuile.getSafe except that it returns a
harmless object that may or may not have any similarity to the original
input (in some cases you may not care).
|
void |
setMaxCardLength(int maxCardLength) |
void |
setStringValidatorRule(StringValidationRule ccrule) |
protected boolean |
validCreditCardFormat(String ccNum)
Performs additional validation on the card nummber.
|
assertValid, charArrayToSet, getEncoder, getSafe, getTypeName, getValid, isAllowNull, isValid, setAllowNull, setEncoder, setTypeName, whitelist, whitelist
protected static final String CREDIT_CARD_VALIDATOR_KEY
public CreditCardValidationRule(String typeName, Encoder encoder)
typeName
- a description of the type of card being validatedencoder
- public CreditCardValidationRule(String typeName, Encoder encoder, StringValidationRule validationRule)
public String getValid(String context, String input) throws ValidationException
context
- for logginginput
- the value to be parsedValidationException
- if any validation rules fail, except if the
ESAPI.properties
> property
"Validator.ValidationRule.getValid.ignore509Fix" is set to
true
, which is the default behavior for ESAPI 2.x
releases. See ESAPI GitHub Issues
521
for futher details.ValidationRule.getValid(String context, String input, ValidationErrorList errorList)
protected boolean validCreditCardFormat(String ccNum)
ccNum
- number to be validatedpublic String sanitize(String context, String input)
sanitize
in class BaseValidationRule
public void setStringValidatorRule(StringValidationRule ccrule)
ccrule
- the ccrule to setpublic StringValidationRule getStringValidatorRule()
public void setMaxCardLength(int maxCardLength)
maxCardLength
- the maxCardLength to setpublic int getMaxCardLength()
Copyright © 2022 The Open Web Application Security Project (OWASP). All rights reserved.