Package com.alibaba.fastjson2.util
Class RegexValidator
java.lang.Object
com.alibaba.fastjson2.util.RegexValidator
-
Constructor Summary
ConstructorsConstructorDescriptionRegexValidator(String regex) Construct a case sensitive validator for a single regular expression.RegexValidator(String[] regexs) Construct a case sensitive validator that matches any one of the set of regular expressions.RegexValidator(String[] regexs, boolean caseSensitive) Construct a validator that matches any one of the set of regular expressions with the specified case sensitivity.RegexValidator(String regex, boolean caseSensitive) Construct a validator for a single regular expression with the specified case sensitivity. -
Method Summary
Modifier and TypeMethodDescriptionbooleanValidate a value against the set of regular expressions.String[]Validate a value against the set of regular expressions returning the array of matched groups.toString()Provide a String representation of this validator.Validate a value against the set of regular expressions returning a String value of the aggregated groups.
-
Constructor Details
-
RegexValidator
Construct a case sensitive validator for a single regular expression.- Parameters:
regex- The regular expression this validator will validate against
-
RegexValidator
Construct a validator for a single regular expression with the specified case sensitivity.- Parameters:
regex- The regular expression this validator will validate againstcaseSensitive- whentruematching is case sensitive, otherwise matching is case in-sensitive
-
RegexValidator
Construct a case sensitive validator that matches any one of the set of regular expressions.- Parameters:
regexs- The set of regular expressions this validator will validate against
-
RegexValidator
Construct a validator that matches any one of the set of regular expressions with the specified case sensitivity.- Parameters:
regexs- The set of regular expressions this validator will validate againstcaseSensitive- whentruematching is case sensitive, otherwise matching is case in-sensitive
-
-
Method Details
-
isValid
Validate a value against the set of regular expressions.- Parameters:
value- The value to validate.- Returns:
trueif the value is valid otherwisefalse.
-
match
Validate a value against the set of regular expressions returning the array of matched groups.- Parameters:
value- The value to validate.- Returns:
- String array of the groups matched if
valid or
nullif invalid
-
validate
Validate a value against the set of regular expressions returning a String value of the aggregated groups.- Parameters:
value- The value to validate.- Returns:
- Aggregated String value comprised of the
groups matched if valid or
nullif invalid
-
toString
Provide a String representation of this validator.
-