SlideShare a Scribd company logo
1 of 14
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

Similar to Validation module in mule

Similar to Validation module in mule (20)

Flows in mule
Flows in muleFlows in mule
Flows in mule
 
What are Anypoint Validations With Mulesoft
What are Anypoint Validations With Mulesoft What are Anypoint Validations With Mulesoft
What are Anypoint Validations With Mulesoft
 
Mule security-jaas
Mule security-jaasMule security-jaas
Mule security-jaas
 
Mule security jaas
Mule security jaasMule security jaas
Mule security jaas
 
Mule security jaas
Mule security jaasMule security jaas
Mule security jaas
 
Mule security - jaas
Mule  security - jaasMule  security - jaas
Mule security - jaas
 
Mule security jaas
Mule security jaasMule security jaas
Mule security jaas
 
Mule security jaas
Mule security jaasMule security jaas
Mule security jaas
 
Mule security jaas
Mule security jaasMule security jaas
Mule security jaas
 
Mule security - jaas
Mule  security - jaasMule  security - jaas
Mule security - jaas
 
Mule security jaas
Mule security jaasMule security jaas
Mule security jaas
 
Mule security - jaas
Mule  security - jaasMule  security - jaas
Mule security - jaas
 
MULE-JAAS
MULE-JAASMULE-JAAS
MULE-JAAS
 
Mule testing
Mule testingMule testing
Mule testing
 
Generating Test Cases
Generating Test CasesGenerating Test Cases
Generating Test Cases
 
Railsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUDRailsplitter: Simplify Your CRUD
Railsplitter: Simplify Your CRUD
 
Wheels
WheelsWheels
Wheels
 
Validation
ValidationValidation
Validation
 
A comprehensive guide to mule soft mule 4
A comprehensive guide to mule soft mule 4A comprehensive guide to mule soft mule 4
A comprehensive guide to mule soft mule 4
 
Pandora FMS: End to End Exchange Plugin
Pandora FMS: End to End Exchange PluginPandora FMS: End to End Exchange Plugin
Pandora FMS: End to End Exchange Plugin
 

More from Ankit Lawaniya

More from Ankit Lawaniya (12)

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

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

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