com.vaadin.flow.data.validator.
Class RegexpValidator
All Implemented Interfaces:
Validator<String>
, Serializable
, BiFunction<String,
Direct Known Subclasses:
A string validator comparing the string against a Java regular expression. Both complete matches and substring matches are supported.
For the Java regular expression syntax, see Pattern
.
Since:
1.0.
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRegexpValidator
(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.
-
Method Summary
Modifier and TypeMethodDescriptionapply
(String value, ValueContext context) Validates the given value.
protected boolean
Returns whether the given string matches the regular expression.
toString()
Methods inherited from class com.vaadin.flow.data.validator.AbstractValidator
getMessage, toResult
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.function.BiFunction
andThen
-
Constructor Details
-
RegexpValidator
Creates a validator for checking that the regular expression matches the complete string to validate.
Parameters:
errorMessage
- the message to display in case the value does not validate.regexp
- a Java regular expression -
RegexpValidator
Creates a validator for checking that the regular expression matches the string to validate.
Parameters:
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 substring
-
-
Method Details
-
apply
Description copied from interface:
Validator
Validates the given value. Returns a
ValidationResult
instance representing the outcome of the validation.Parameters:
value
- the input value to validatecontext
- the value context for validationReturns:
the validation result
-
toString
-
isValid
Returns whether the given string matches the regular expression.
Parameters:
value
- the string to matchReturns:
true if the string matched, false otherwise
-