public final class ValidationFunctions extends Object
AbstractValidator's from a
MEL context.
Unlike regular validations which throw an exception upon failure, the methods in this class will only return boolean values to
indicate if the validation was successful or not. Also, no message is returned in either case.
Since in this case we only care about the boolean result of the validation, all validations will be executed with the same
ValidationContext
Validator instances are not reused. A new one is created each time| Constructor and Description |
|---|
ValidationFunctions() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isEmail(String email)
Tests if the
email address is validm |
boolean |
isIp(String ip)
Tests if the
ip is valid |
boolean |
isNumber(String value,
NumberType numberType)
|
boolean |
isTime(String time,
String pattern,
String locale)
|
boolean |
isUrl(String url)
Tests if the
url is a valid one. |
boolean |
matchesRegex(String value,
String regex,
boolean caseSensitive)
Tests if the
value matches the regex regular expression |
public boolean isEmail(String email)
email address is validmemail - an email addresstrue if the validation succeeded. false otherwisepublic boolean matchesRegex(String value, String regex, @Optional(defaultValue="true") boolean caseSensitive)
value matches the regex regular expressionvalue - the value to checkregex - the regular expression to check againstcaseSensitive - when true matching is case sensitive, otherwise matching is case in-sensitivetrue if the validation succeeded. false otherwisepublic boolean isTime(String time, @Optional String pattern, @Optional String locale)
time in String format is valid for the given pattern and locale. If no
pattern is provided, then the locale's default will be usedtime - A date in String formatpattern - the pattern for the datelocale - a Locale keytrue if the validation succeeded. false otherwisepublic boolean isNumber(String value, NumberType numberType)
value can be parsed into a Number, by the rules of a NumberValidator.
No boundaries are checked. Default system pattern and Locale are usedvalue - the value to testnumberType - the type of number to validate againsttrue if the validation succeeded. false otherwisepublic boolean isIp(String ip)
ip is validip - the ip address to validatetrue if the validation succeeded. false otherwiseCopyright © 2023 MuleSoft, Inc.. All rights reserved.