public final class CommonValidationOperations extends Object
ValidationExtension
which executes the Validator
s that the extension
provides out of the boxValidationExtension
Constructor and Description |
---|
CommonValidationOperations() |
Modifier and Type | Method and Description |
---|---|
protected ValidationContext |
createContext(ValidationOptions options,
MuleEvent muleEvent,
ValidationExtension config) |
void |
isEmail(String email,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
Validates that the
email address is valid |
void |
isEmpty(Object value,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
Validates that
value is empty. |
void |
isFalse(boolean expression,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
Validates that the given
value is false |
void |
isIp(String ip,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
Validates that an
ip address represented as a String is valid |
void |
isNotEmpty(Object value,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
Validates that
value is not empty. |
void |
isNotNull(Object value,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
|
void |
isNull(Object value,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
|
void |
isTime(String time,
String locale,
String pattern,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
|
void |
isTrue(boolean expression,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
Validates that the given
value is true |
void |
isUrl(String url,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
Validates that
url is a valid one |
protected void |
logSuccessfulValidation(Validator validator,
MuleEvent event) |
void |
matchesRegex(String value,
String regex,
boolean caseSensitive,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
Validates that
value matches the regex regular expression |
protected Locale |
parseLocale(String locale) |
void |
validateSize(Object value,
int min,
Integer max,
ValidationOptions options,
MuleEvent event,
ValidationExtension config)
Validates that
value has a size between certain inclusive boundaries. |
protected void |
validateWith(Validator validator,
ValidationContext validationContext,
MuleEvent event) |
protected final Logger logger
@Operation public void isTrue(boolean expression, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
value
is true
expression
- the boolean to testoptions
- the ValidationOptions
event
- the current {@link MuleEventconfig
- the current ValidationExtension
that serves as configException
- if the value is not true
@Operation public void isFalse(boolean expression, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
value
is false
expression
- the boolean to testoptions
- the ValidationOptions
event
- the current {@link MuleEventconfig
- the current ValidationExtension
that serves as configException
- if the value is not true
@Operation public void isEmail(String email, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
email
address is validemail
- an email addressoptions
- the ValidationOptions
event
- the current {@link MuleEventconfig
- the current ValidationExtension
that serves as configException
@Operation public void isIp(String ip, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
ip
address represented as a String
is validip
- the ip address to validateoptions
- the ValidationOptions
event
- the current {@link MuleEventconfig
- the current ValidationExtension
that serves as configException
@Operation public void validateSize(Object value, @Optional(defaultValue="0") int min, @Optional Integer max, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
value
has a size between certain inclusive boundaries. This
validator is capable of handling instances of String
, Collection
,
Map
and arraysvalue
- 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 lengthoptions
- the ValidationOptions
event
- the current {@link MuleEventconfig
- the current ValidationExtension
that serves as configException
@Operation public void isNotEmpty(Object value, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
value
is not empty. The definition of empty depends on
the type of value
. If it's a String
it will check that it is not blank.
If it's a Collection
, array or Map
it will check that it's not empty. No other types
are supported, an IllegalArgumentException
will be thrown if any other type is suppliedvalue
- the value to checkoptions
- the ValidationOptions
event
- the current {@link MuleEventconfig
- the current ValidationExtension
that serves as configIllegalArgumentException
- if value
is something other than a String
,Collection
or Map
Exception
@Operation public void isEmpty(Object value, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
value
is empty. The definition of empty depends on
the type of value
. If it's a String
it will check that it is not blank.
If it's a Collection
, array or Map
it will check that it's not empty. No other types
are supported, an IllegalArgumentException
will be thrown if any other type is suppliedvalue
- the value to checkoptions
- the ValidationOptions
event
- the current MuleEvent
config
- the current ValidationExtension
that serves as configIllegalArgumentException
- if value
is something other than a String
,Collection
or Map
Exception
@Operation public void isNotNull(Object value, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
value
- the value to testoptions
- the ValidationOptions
event
- the current MuleEvent
config
- the current ValidationExtension
that serves as configException
@Operation public void isNull(Object value, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
value
- the value to testoptions
- the ValidationOptions
event
- the current MuleEvent
config
- the current ValidationExtension
that serves as configException
@Operation public void isTime(String time, @Optional String locale, @Optional String pattern, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
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 formatlocale
- the locale of the Stringpattern
- the pattern for the date
options
- the ValidationOptions
event
- the current MuleEvent
config
- the current ValidationExtension
that serves as configException
@Operation public void isUrl(String url, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
url
is a valid oneurl
- the URL to validate as a String
options
- the ValidationOptions
event
- the current MuleEvent
config
- the current ValidationExtension
that serves as configException
@Operation public void matchesRegex(String value, String regex, @Optional(defaultValue="true") boolean caseSensitive, @ParameterGroup ValidationOptions options, MuleEvent event, @UseConfig ValidationExtension config) throws Exception
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-sensitiveoptions
- the ValidationOptions
event
- the current MuleEvent
config
- the current ValidationExtension
that serves as configException
protected void validateWith(Validator validator, ValidationContext validationContext, MuleEvent event) throws Exception
Exception
protected ValidationContext createContext(ValidationOptions options, MuleEvent muleEvent, ValidationExtension config)
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.