@Validator 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 static String |
ERROR_GROUP |
protected static org.slf4j.Logger |
LOGGER |
| Constructor and Description |
|---|
CommonValidationOperations() |
| Modifier and Type | Method and Description |
|---|---|
protected ValidationContext |
createContext(ValidationOptions options,
ValidationExtension config) |
void |
isEmail(String email,
ValidationOptions options,
ValidationExtension config)
Validates that the
email address is valid |
void |
isEmpty(Object value,
ValidationOptions options,
ValidationExtension config)
Validates that
value is empty. |
void |
isFalse(boolean expression,
ValidationOptions options,
ValidationExtension config)
Validates that the given
value is false |
void |
isIp(String ip,
ValidationOptions options,
ValidationExtension config)
Validates that an
ip address represented as a String is valid |
void |
isNotEmpty(Object value,
ValidationOptions options,
ValidationExtension config)
Validates that
value is not empty. |
void |
isNotNull(Object value,
ValidationOptions options,
ValidationExtension config)
Validates that the given
value is not null. |
void |
isNull(Object value,
ValidationOptions options,
ValidationExtension config)
Validates that the given
value is null. |
void |
isTime(String time,
String locale,
String pattern,
ValidationOptions options,
ValidationExtension config)
|
void |
isTrue(boolean expression,
ValidationOptions options,
ValidationExtension config)
Validates that the given
value is true |
void |
isUrl(String url,
ValidationOptions options,
ValidationExtension config)
Validates that
url is a valid one |
protected void |
logSuccessfulValidation(Validator validator) |
void |
matchesRegex(String value,
String regex,
boolean caseSensitive,
ValidationOptions options,
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,
ValidationExtension config)
Validates that
value has a size between certain inclusive boundaries. |
protected void |
validateWith(Validator validator,
ValidationContext validationContext) |
protected static final String ERROR_GROUP
protected static final org.slf4j.Logger LOGGER
@Throws(value=BooleanErrorType.class) public void isTrue(boolean expression, @ParameterGroup(name="Error options") ValidationOptions options, @Config ValidationExtension config) throws Exception
value is trueexpression - the boolean to testoptions - the ValidationOptionsconfig - the current ValidationExtension that serves as configException - if the value is not true@Throws(value=BooleanErrorType.class) public void isFalse(boolean expression, @ParameterGroup(name="Error options") ValidationOptions options, @Config ValidationExtension config) throws Exception
value is falseexpression - the boolean to testoptions - the ValidationOptionsconfig - the current ValidationExtension that serves as configException - if the value is not true@Throws(value=EmailErrorType.class) public void isEmail(String email, @ParameterGroup(name="Error options") ValidationOptions options, @Config ValidationExtension config) throws Exception
email address is validemail - an email addressoptions - the ValidationOptionsconfig - the current ValidationExtension that serves as configException@DisplayName(value="Is IP") @Throws(value=IpErrorType.class) public void isIp(String ip, @ParameterGroup(name="Error options") ValidationOptions options, @Config ValidationExtension config) throws Exception
ip address represented as a String is validip - the ip address to validateoptions - the ValidationOptionsconfig - the current ValidationExtension that serves as configException@Throws(value=SizeErrorType.class) public void validateSize(Object value, @Optional(defaultValue="0") int min, @Optional Integer max, @ParameterGroup(name="Error options") ValidationOptions options, @Config 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 ValidationOptionsconfig - the current ValidationExtension that serves as configException@Throws(value=EmptyErrorType.class) public void isNotEmpty(@Optional(defaultValue="#[payload]") Object value, @ParameterGroup(name="Error options") ValidationOptions options, @Config 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 ValidationOptionsconfig - the current ValidationExtension that serves as configIllegalArgumentException - if value is something other than a String,Collection or MapException@Throws(value=NotEmptyErrorType.class) public void isEmpty(Object value, @ParameterGroup(name="Error options") ValidationOptions options, @Config 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 ValidationOptionsconfig - the current ValidationExtension that serves as configIllegalArgumentException - if value is something other than a String,Collection or MapException@Throws(value=NullErrorType.class) public void isNotNull(Object value, @ParameterGroup(name="Error options") ValidationOptions options, @Config ValidationExtension config) throws Exception
value is not null.value - the value to testoptions - the ValidationOptionsconfig - the current ValidationExtension that serves as configException@Throws(value=NotNullErrorType.class) public void isNull(Object value, @ParameterGroup(name="Error options") ValidationOptions options, @Config ValidationExtension config) throws Exception
value is null.value - the value to testoptions - the ValidationOptionsconfig - the current ValidationExtension that serves as configException@Throws(value=TimeErrorType.class) public void isTime(String time, @Optional String locale, @Optional String pattern, @ParameterGroup(name="Error options") ValidationOptions options, @Config 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 dateoptions - the ValidationOptionsconfig - the current ValidationExtension that serves as configException@DisplayName(value="Is URL") @Throws(value=UrlErrorType.class) public void isUrl(@DisplayName(value="URL") String url, @ParameterGroup(name="Error options") ValidationOptions options, @Config ValidationExtension config) throws Exception
url is a valid oneurl - the URL to validate as a Stringoptions - the ValidationOptionsconfig - the current ValidationExtension that serves as configException@Throws(value=RegexErrorType.class) public void matchesRegex(String value, String regex, @Optional(defaultValue="true") boolean caseSensitive, @ParameterGroup(name="Error options") ValidationOptions options, @Config 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 ValidationOptionsconfig - the current ValidationExtension that serves as configExceptionprotected void validateWith(Validator validator, ValidationContext validationContext) throws Exception
Exceptionprotected ValidationContext createContext(ValidationOptions options, ValidationExtension config)
protected void logSuccessfulValidation(Validator validator)
Copyright © 2017 MuleSoft, Inc.. All rights reserved.