2. AnypointValidation
Validations is out-of-box feature available with Mulesoft to verify the content
of message in the Mule flow like validating the date format, email address, url,
IP etc.The advantage of validations over the filters is traceability. Filter raised
the all identical exceptions which is difficult to understand where the
exceptions was raised where as validations provide exceptions with some
meaningful message and its easy to understand.
• If message doesn't meets a specified criteria, the validation fails and
ValidationException will be raised.
• Exception raised have a meaningful message attached.You can optionally
customize the message as well as exception raised.
• There is facility to build your own custom validator if out-of-box validations
doesn't match your requirements.
Validator can be used as Message Processor as well as MEL (Mule Expression
Language).
6. AnypointValidation
Validate Size
It is used validate the input message size between min and max boundaries. It's
valid for inputs like Map, Array, String andCollections.
8. AnypointValidation
Validate String, Collection or Map Is Not Empty
In case of String, the definition of not empty is if length of input data is greater
than zero and in case of Map and Collection, the definition of not empty, it refers
how many items it contains.
9. AnypointValidation
IsTrue and Is False FallbackValidators
You have seen many validations above and sometime there might be scenario
which cannot be meet from above validations. So you can use two fallback
validators, to evaluate the expression isTrue or is False.
10. AnypointValidation
Validating Multiple Conditions at Once
There may be scenario where you need to validate the several conditions. If more than
one condition fails, it is ideal to generate a single error with all the description.
• Validators are executed sequentially in flow's thread.
• All validations are executed, even all validations fails.
• Unlike the rest of the validators, the all validator does not allow you to directly
customize the exception type or the message through validation
• If any of the validators fails, only single error will be thrown.