public class RegExValidator extends Object implements FieldValidator
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_MESSAGE_FORMAT |
Constructor and Description |
---|
RegExValidator(Pattern pattern)
Build a validator with the provided pattern.
|
RegExValidator(String regex)
Build a validator by compiling the provided regex.
|
RegExValidator(String regex,
int flags)
Build a validator by compiling the provided regex and associated flags.
|
Modifier and Type | Method and Description |
---|---|
void |
setMessageFormat(String messagePattern)
Set the message formatter pattern to be used for validation error message.
|
void |
validate(Field field)
Validates the field value is properly formatted.
|
public static final String DEFAULT_MESSAGE_FORMAT
public RegExValidator(Pattern pattern)
pattern
- Regex pattern.public RegExValidator(String regex)
regex
- String representation of the regex.Pattern.compile(String)
public RegExValidator(String regex, int flags)
regex
- String representation of the regex.flags
- Regex matching flags.Pattern.compile(String, int)
public void setMessageFormat(String messagePattern)
messagePattern
- The actual message formatter patter. {0} is the field name and {1} is the field value.MessageFormat
public void validate(Field field) throws ValidationException
validate
in interface FieldValidator
field
- The field to be validate.ValidationException
- If the field value is not formatted correctly.Copyright 2019 Ping Identity Corp. All rights reserved.