public final class ValidatorElContext 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 timeConstructor and Description |
---|
ValidatorElContext() |
ValidatorElContext(MuleEvent event) |
Modifier and Type | Method and Description |
---|---|
boolean |
isEmpty(Object value)
Validates that
value is empty by using
a EmptyValidator |
boolean |
isNotNull(Object value)
|
boolean |
isNull(Object value)
|
boolean |
isNumber(String value,
NumberType numberType)
|
boolean |
isNumber(String value,
NumberType numberType,
Number minValue,
Number maxValue)
|
boolean |
isNumber(String value,
NumberType numberType,
Number minValue,
Number maxValue,
String pattern,
String locale)
|
boolean |
isTime(String time,
String pattern)
Validates that
time represents a time according to the
given pattern an the default locale ValidationExtension#DEFAULT_LOCALE)
using a {@link TimeValidator} |
boolean |
isTime(String time,
String pattern,
String locale)
Validates that
time represents a time according to the
given pattern an the given locale locale
using a TimeValidator
{@code locale} is expected to be a valid key as defined in
{@link Locale} |
boolean |
matchesRegex(String value,
String regex,
boolean caseSensitive)
|
boolean |
notEmpty(Object value)
Validates that
value is not empty by using
a NotEmptyValidator |
boolean |
validateEmail(String email)
Validates the given
email using a EmailValidator |
boolean |
validateIp(String ip)
|
boolean |
validateSize(Object value,
int min,
int max)
Validates that
value has a size between certain inclusive boundaries by
using a SizeValidator |
boolean |
validateUrl(String url)
Validates that
url is a valid one
by using a UrlValidator . |
public ValidatorElContext(MuleEvent event)
public ValidatorElContext()
public boolean validateEmail(String email)
email
using a EmailValidator
email
- an email addresstrue
if the validation succeeded. false
otherwisepublic boolean matchesRegex(String value, String regex, boolean caseSensitive)
value
- 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, String pattern)
time
represents a time according to the
given pattern
an the default locale ValidationExtension#DEFAULT_LOCALE)
using a {@link TimeValidator}time
- A date in String formatpattern
- the pattern for the date
true
if the validation succeeded. false
otherwisepublic boolean isTime(String time, String pattern, String locale)
time
represents a time according to the
given pattern
an the given locale locale
using a TimeValidator
{@code locale} is expected to be a valid key as defined in
{@link Locale}time
- A date in String formatpattern
- the pattern for the date
locale
- a Locale
keytrue
if the validation succeeded. false
otherwisepublic boolean isEmpty(Object value)
value
is empty by using
a EmptyValidator
value
- the value to checktrue
if the validation succeeded. false
otherwisepublic boolean notEmpty(Object value)
value
is not empty by using
a NotEmptyValidator
value
- the value to checktrue
if the validation succeeded. false
otherwisepublic boolean validateSize(Object value, int min, int max)
value
has a size between certain inclusive boundaries by
using a SizeValidator
value
- the value to validatemin
- the minimum expected length (inclusive, defaults to zero)max
- the maximum expected length (inclusive). Leave unspecified or null
to allow any max lengthtrue
if the validation succeeded. false
otherwisepublic boolean isNotNull(Object value)
value
- the value to testtrue
if the validation succeeded. false
otherwisepublic boolean isNull(Object value)
value
- the value to testtrue
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 isNumber(String value, NumberType numberType, Number minValue, Number maxValue)
value
can be parsed into a Number
,
by the rules of a NumberValidator
.
Default system pattern and Locale
are usedvalue
- the value to testnumberType
- the type of number to validate againstminValue
- if not null
, the parsed number is checked to be greater or equal than thisminValue
- if not null
, the parsed number is checked to be lower or equal than thistrue
if the validation succeeded. false
otherwisepublic boolean isNumber(String value, NumberType numberType, Number minValue, Number maxValue, String pattern, String locale)
value
- the value to testnumberType
- the type of number to validate againstminValue
- if not null
, the parsed number is checked to be greater or equal than thisminValue
- if not null
, the parsed number is checked to be lower or equal than thispattern
- the pattern to use when parsing the value
locale
- the locale as a String
to use when parsing the value
true
if the validation succeeded. false
otherwisepublic boolean validateIp(String ip)
ip
- the ip address to validatetrue
if the validation succeeded. false
otherwisepublic boolean validateUrl(String url)
url
is a valid one
by using a UrlValidator
.url
- the URL to validate as a String
true
if the validation succeeded. false
otherwiseCopyright © 2003–2016 MuleSoft, Inc.. All rights reserved.