public class RegexpValidator extends AbstractValidator<String>
For the Java regular expression syntax, see Pattern
.
Constructor and Description |
---|
RegexpValidator(String errorMessage,
String regexp)
Creates a validator for checking that the regular expression matches the
complete string to validate.
|
RegexpValidator(String errorMessage,
String regexp,
boolean complete)
Creates a validator for checking that the regular expression matches the
string to validate.
|
Modifier and Type | Method and Description |
---|---|
ValidationResult |
apply(String value,
ValueContext context)
Validates the given value.
|
protected boolean |
isValid(String value)
Returns whether the given string matches the regular expression.
|
String |
toString() |
getMessage, toResult
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
alwaysPass, from, from, from, from
andThen
public RegexpValidator(String errorMessage, String regexp)
errorMessage
- the message to display in case the value does not validate.regexp
- a Java regular expressionpublic RegexpValidator(String errorMessage, String regexp, boolean complete)
errorMessage
- the message to display in case the value does not validate.regexp
- a Java regular expressioncomplete
- true to use check for a complete match, false to look for a
matching substringpublic ValidationResult apply(String value, ValueContext context)
Validator
ValidationResult
instance
representing the outcome of the validation.value
- the input value to validatecontext
- the value context for validationprotected boolean isValid(String value)
value
- the string to matchCopyright © 2022. All rights reserved.