SlideShare a Scribd company logo
Ankit Lawaniya
9/3/2017 Ankit Lawaniya 1
The Validation module provides an easy out-of-the-box way to verify that the
content of a message in your flow matches a given set of criteria.
The Difference Between Mule's Filter Component and Validation Module
The main advantage of the Validation Module over using filters is
traceability, as filters all raise identical exceptions, making it hard for us to
know where the exception was caused. So if we have two filters in the same
flow, we cannot know which one failed and we cannot customize the
exception type. Validators, on the other hand, raise an exception with a
meaningful message attached, so we can customize the exception type.
Note: This feature is supported by the Mule run-time as of Mule ESB 3.7.0
in both Community and Enterprise editions.
9/3/2017 Ankit Lawaniya 2
The validations module was designed following these principles:
 If the message doesn’t meet the specified criteria, the validation fails
and a ValidationException is thrown.
 By default, this exception has a meaningful message attached. You
can optionally customize this message and change the type of
exception thrown, as long as the new exception type has a constructor
that overrides Exception(String).
 In case you want to throw an Exception type that lacks this
constructor, or in which its creation is not trivial, or in which you
want it to contain additional information
9/3/2017 Ankit Lawaniya 3
 There are two ways of using a validator: through a Message Processor, or
through a MEL function.
9/3/2017 Ankit Lawaniya 4
Below is not the complete list of Validators; please refer to the
MuleSoft article on Validation components for the complete list.
 Email Address Validator
<validation:is-email email=”#[json:email]” />
 Not Empty check Validator
<validation:is-not-empty value=”#[json:employeeId]”
message=”Employee Id is mandatory to supply” />
 Size Validator
<validation:validate-size value=”#[json:age]” min=”2″ max=”3″
message=”Please provide correct age” />
 Not Null Validator
<validation:not-null expression=”#[value]” value=”#[payload]” />
 Number Validator
<validation:is-number value=”#[json:Id]” numberType=”INTEGER”
message=”ID can not be String or any other data Type” />
9/3/2017 Ankit Lawaniya 5
There are scenarios in which you may want to evaluate several conditions,
out of which more than one could fail simultaneously. In these cases, it’s ideal
to generate a single error that contains all of the descriptions.
The solution is the All Validator.
Let’s walk through how to use All Validator in a Mule application. In this
example, we are receiving the JSON Request through an HTTP call from the
REST client, which will be validated against the ALL Validator Component.
9/3/2017 Ankit Lawaniya 6
9/3/2017 Ankit Lawaniya 7
9/3/2017 Ankit Lawaniya 8
{
“id”: 123,
“account”: 1234,
“name”:”Ankit”,
“age”: 24 ,
“email” :”ankit.lawaniya@live.com”
}
9/3/2017 Ankit Lawaniya 9
9/3/2017 Ankit Lawaniya 10
{
"id": "dummyId",
"account": 12,
"name":"Ankit1",
"age": 2 ,
"email" :"ankit.lawaniyalive.com"
}
9/3/2017 Ankit Lawaniya 11
9/3/2017 Ankit Lawaniya 12
Below is the exception thrown for the validation failure:
Root Exception stack trace:
org.mule.extension.validation.api.MultipleValidationException: ID
can not be String data Type
Name can not contain Integer value and other special charectors
Please provide correct age
ankit.lawaniyalive.com is not a valid email address
at
org.mule.extension.validation.internal.ValidationStrategies.all(Vali
dationStrategies.java:71)
9/3/2017 Ankit Lawaniya 13
9/3/2017 Ankit Lawaniya 14

More Related Content

PPT
Mule security - authorization using spring security
PPT
Mule security - jaas
ODT
Sql injection
PPTX
SQL Injection attack
PDF
XSS And SQL Injection Vulnerabilities
PPTX
Mule validators
PPTX
Flows in mule
PPTX
Flowsinmule 160517130818
Mule security - authorization using spring security
Mule security - jaas
Sql injection
SQL Injection attack
XSS And SQL Injection Vulnerabilities
Mule validators
Flows in mule
Flowsinmule 160517130818

Similar to Validation module in mule (20)

PPTX
Flows in mule
PDF
What are Anypoint Validations With Mulesoft
PPT
Mule security-jaas
PPT
Mule security jaas
PPT
Mule security jaas
PPT
Mule security jaas
PPT
Mule security jaas
PPT
Mule security - jaas
PPT
Mule security - jaas
PPT
Mule security jaas
PPT
Mule security jaas
PPT
Mule security - jaas
PPT
MULE-JAAS
PPTX
Mule testing
PPTX
Generating Test Cases
PDF
Railsplitter: Simplify Your CRUD
PDF
Model-Based Testing in The Test Automation
DOC
Wheels
PDF
How to Write Test Scenarios That Ensure App Success.pdf
PPTX
Flows in mule
What are Anypoint Validations With Mulesoft
Mule security-jaas
Mule security jaas
Mule security jaas
Mule security jaas
Mule security jaas
Mule security - jaas
Mule security - jaas
Mule security jaas
Mule security jaas
Mule security - jaas
MULE-JAAS
Mule testing
Generating Test Cases
Railsplitter: Simplify Your CRUD
Model-Based Testing in The Test Automation
Wheels
How to Write Test Scenarios That Ensure App Success.pdf
Ad

More from Ankit Lawaniya (12)

PPTX
Content based routing using mule choice flow control
PPTX
Until successful scope in mule
PPTX
First successful-router
PPTX
Iterative processing using the for each scope in
PPTX
Improving performance with cache scope in mule
PPTX
Cors (cross origin request sharing) in mule
PPTX
Content enrichment using mule message enricher
PPTX
Schema validation filter (xml schema validation)
PPTX
Validate json schema component
PPTX
Parse template transformer mule
PPTX
Active mq read and write flow in mule
PPTX
Composite source in mule
Content based routing using mule choice flow control
Until successful scope in mule
First successful-router
Iterative processing using the for each scope in
Improving performance with cache scope in mule
Cors (cross origin request sharing) in mule
Content enrichment using mule message enricher
Schema validation filter (xml schema validation)
Validate json schema component
Parse template transformer mule
Active mq read and write flow in mule
Composite source in mule
Ad

Recently uploaded (20)

PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
cuic standard and advanced reporting.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Reach Out and Touch Someone: Haptics and Empathic Computing
cuic standard and advanced reporting.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Electronic commerce courselecture one. Pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Diabetes mellitus diagnosis method based random forest with bat algorithm
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars
Mobile App Security Testing_ A Comprehensive Guide.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Digital-Transformation-Roadmap-for-Companies.pptx
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Validation module in mule

  • 2. The Validation module provides an easy out-of-the-box way to verify that the content of a message in your flow matches a given set of criteria. The Difference Between Mule's Filter Component and Validation Module The main advantage of the Validation Module over using filters is traceability, as filters all raise identical exceptions, making it hard for us to know where the exception was caused. So if we have two filters in the same flow, we cannot know which one failed and we cannot customize the exception type. Validators, on the other hand, raise an exception with a meaningful message attached, so we can customize the exception type. Note: This feature is supported by the Mule run-time as of Mule ESB 3.7.0 in both Community and Enterprise editions. 9/3/2017 Ankit Lawaniya 2
  • 3. The validations module was designed following these principles:  If the message doesn’t meet the specified criteria, the validation fails and a ValidationException is thrown.  By default, this exception has a meaningful message attached. You can optionally customize this message and change the type of exception thrown, as long as the new exception type has a constructor that overrides Exception(String).  In case you want to throw an Exception type that lacks this constructor, or in which its creation is not trivial, or in which you want it to contain additional information 9/3/2017 Ankit Lawaniya 3
  • 4.  There are two ways of using a validator: through a Message Processor, or through a MEL function. 9/3/2017 Ankit Lawaniya 4
  • 5. Below is not the complete list of Validators; please refer to the MuleSoft article on Validation components for the complete list.  Email Address Validator <validation:is-email email=”#[json:email]” />  Not Empty check Validator <validation:is-not-empty value=”#[json:employeeId]” message=”Employee Id is mandatory to supply” />  Size Validator <validation:validate-size value=”#[json:age]” min=”2″ max=”3″ message=”Please provide correct age” />  Not Null Validator <validation:not-null expression=”#[value]” value=”#[payload]” />  Number Validator <validation:is-number value=”#[json:Id]” numberType=”INTEGER” message=”ID can not be String or any other data Type” /> 9/3/2017 Ankit Lawaniya 5
  • 6. There are scenarios in which you may want to evaluate several conditions, out of which more than one could fail simultaneously. In these cases, it’s ideal to generate a single error that contains all of the descriptions. The solution is the All Validator. Let’s walk through how to use All Validator in a Mule application. In this example, we are receiving the JSON Request through an HTTP call from the REST client, which will be validated against the ALL Validator Component. 9/3/2017 Ankit Lawaniya 6
  • 9. { “id”: 123, “account”: 1234, “name”:”Ankit”, “age”: 24 , “email” :”ankit.lawaniya@live.com” } 9/3/2017 Ankit Lawaniya 9
  • 11. { "id": "dummyId", "account": 12, "name":"Ankit1", "age": 2 , "email" :"ankit.lawaniyalive.com" } 9/3/2017 Ankit Lawaniya 11
  • 13. Below is the exception thrown for the validation failure: Root Exception stack trace: org.mule.extension.validation.api.MultipleValidationException: ID can not be String data Type Name can not contain Integer value and other special charectors Please provide correct age ankit.lawaniyalive.com is not a valid email address at org.mule.extension.validation.internal.ValidationStrategies.all(Vali dationStrategies.java:71) 9/3/2017 Ankit Lawaniya 13