public interface ValidationRule
Modifier and Type | Method and Description |
---|---|
void |
assertValid(String context,
String input)
Check if the input is valid, throw an Exception otherwise
|
Object |
getSafe(String context,
String input)
Try to call
getvalid , then call a 'sanitize' method for sanitization (if one exists),
finally return a default value. |
String |
getTypeName()
Programmatically supplied name for the validator
|
Object |
getValid(String context,
String input)
Parse the input, throw exceptions if validation fails
|
Object |
getValid(String context,
String input,
ValidationErrorList errorList)
Get a validated value, add the errors to an existing error list
|
boolean |
isValid(String context,
String input) |
void |
setAllowNull(boolean flag)
Whether or not a valid valid can be null.
|
void |
setEncoder(Encoder encoder) |
void |
setTypeName(String typeName) |
String |
whitelist(String input,
char[] list)
String the input of all chars contained in the list
|
String |
whitelist(String input,
Set<Character> list)
String the input of all chars contained in the list
|
Object getValid(String context, String input) throws ValidationException
context
- for logginginput
- the value to be parsedValidationException
- Thrown if any validation rules fail, except when the
ESAPI.properties
> property
"Validator.HtmlValidationAction" is set to
clean
. The default ESAPI.properties
> property file
has "Validator.HtmlValidationAction" is set to throw
, which results
in a ValidationException
being thrown if any of the validation rules
fail.
releases. See ESAPI GitHub Issues
521
for futher details.getValid(String context, String input, ValidationErrorList errorList)
void setAllowNull(boolean flag)
getValid
will throw an
Exception and {#code getSafe} will return the default value if flag is set to
trueflag
- whether or not null values are valid/safeString getTypeName()
void setTypeName(String typeName)
typeName
- a name, describing the validatorvoid setEncoder(Encoder encoder)
encoder
- the encoder to usevoid assertValid(String context, String input) throws ValidationException
ValidationException
Object getValid(String context, String input, ValidationErrorList errorList) throws ValidationException
ValidationException
Object getSafe(String context, String input)
getvalid
, then call a 'sanitize' method for sanitization (if one exists),
finally return a default value.String whitelist(String input, char[] list)
Copyright © 2023 The Open Worldwide Application Security Project (OWASP). All rights reserved.