@ImplementationOf(value=ValidationExtension.class) public final class CommonValidationOperations extends Object
ValidationExtension
which executes the Validators that the extension
provides out of the boxValidationExtension| Modifier and Type | Field and Description |
|---|---|
protected ValidationExtension |
config |
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
CommonValidationOperations(ValidationExtension config) |
| Modifier and Type | Method and Description |
|---|---|
protected ValidationContext |
createContext(ValidationOptions options,
MuleEvent muleEvent) |
void |
isEmail(String email,
ValidationOptions options,
MuleEvent event)
Validates that the
email address is valid |
void |
isEmpty(Object value,
ValidationOptions options,
MuleEvent event)
Validates that
value is empty. |
void |
isFalse(boolean expression,
ValidationOptions options,
MuleEvent event)
Validates that the given
value is false |
void |
isIp(String ip,
ValidationOptions options,
MuleEvent event)
Validates that an
ip address represented as a String is valid |
void |
isNotEmpty(Object value,
ValidationOptions options,
MuleEvent event)
Validates that
value is not empty. |
void |
isNotNull(Object value,
ValidationOptions options,
MuleEvent event)
|
void |
isNull(Object value,
ValidationOptions options,
MuleEvent event)
|
void |
isTime(String time,
String locale,
String pattern,
ValidationOptions options,
MuleEvent event)
|
void |
isTrue(boolean expression,
ValidationOptions options,
MuleEvent event)
Validates that the given
value is true |
void |
isUrl(String url,
ValidationOptions options,
MuleEvent event)
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)
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)
Validates that
value has a size between certain inclusive boundaries. |
protected void |
validateWith(Validator validator,
ValidationContext validationContext,
MuleEvent event) |
protected final org.slf4j.Logger logger
protected final ValidationExtension config
public CommonValidationOperations(ValidationExtension config)
@Operation public void isTrue(boolean expression, @ParameterGroup ValidationOptions options, MuleEvent event) throws Exception
value is trueexpression - the boolean to testoptions - the ValidationOptionsevent - the current {@link MuleEventException - if the value is not true@Operation public void isFalse(boolean expression, @ParameterGroup ValidationOptions options, MuleEvent event) throws Exception
value is falseexpression - the boolean to testoptions - the ValidationOptionsevent - the current {@link MuleEventException - if the value is not true@Operation public void isEmail(String email, @ParameterGroup ValidationOptions options, MuleEvent event) throws Exception
email address is validemail - an email addressoptions - the ValidationOptionsevent - the current {@link MuleEventException@Operation public void isIp(String ip, @ParameterGroup ValidationOptions options, MuleEvent event) throws Exception
ip address represented as a String is validip - the ip address to validateoptions - the ValidationOptionsevent - the current {@link MuleEventException@Operation public void validateSize(Object value, @Optional(defaultValue="0") int min, @Optional Integer max, @ParameterGroup ValidationOptions options, MuleEvent event) 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 ValidationOptionsevent - the current {@link MuleEventException@Operation public void isNotEmpty(Object value, @ParameterGroup ValidationOptions options, MuleEvent event) 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 ValidationOptionsevent - the current {@link MuleEventIllegalArgumentException - if value is something other than a String,Collection or MapException@Operation public void isEmpty(Object value, @ParameterGroup ValidationOptions options, MuleEvent event) 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 ValidationOptionsevent - the current MuleEventIllegalArgumentException - if value is something other than a String,Collection or MapException@Operation public void isNotNull(Object value, @ParameterGroup ValidationOptions options, MuleEvent event) throws Exception
value - the value to testoptions - the ValidationOptionsevent - the current {@link MuleEventException@Operation public void isNull(Object value, @ParameterGroup ValidationOptions options, MuleEvent event) throws Exception
value - the value to testoptions - the ValidationOptionsevent - the current {@link MuleEventException@Operation public void isTime(String time, @Optional String locale, @Optional String pattern, @ParameterGroup ValidationOptions options, MuleEvent event) 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 dateoptions - the ValidationOptionsevent - the current {@link MuleEventException@Operation public void isUrl(String url, @ParameterGroup ValidationOptions options, MuleEvent event) throws Exception
url is a valid oneurl - the URL to validate as a Stringoptions - the ValidationOptionsevent - the current {@link MuleEventException@Operation public void matchesRegex(String value, String regex, @Optional(defaultValue="true") boolean caseSensitive, @ParameterGroup ValidationOptions options, MuleEvent event) 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 ValidationOptionsevent - the current {@link MuleEventExceptionprotected void validateWith(Validator validator, ValidationContext validationContext, MuleEvent event) throws Exception
Exceptionprotected ValidationContext createContext(ValidationOptions options, MuleEvent muleEvent)
Copyright © 2003–2015 MuleSoft, Inc.. All rights reserved.