Validation Component in Mule 4
Validation Component in mule 4 is responsible for validation purposes.
Some of the
examples are as follows-
Is IP:
validates a valid IP address
Flow:
Is IP
settings:
Method: POST
Input &
Output:
Since IP the address is incorrect so it is telling not a valid IP address.
Null: It
checks whether the value is null or not.
Flow:
Is null
settings:
URL: http://localhost:8085/null
Method: POST
Input &
Output:
Since
payload is not null so it is giving an error.
XML project
code:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:validation="http://www.mulesoft.org/schema/mule/validation"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/validation http://www.mulesoft.org/schema/mule/validation/current/mule-validation.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<validation:config name="Validation_Config" doc:name="Validation Config" doc:id="fe5dfcf6-0284-4040-8119-57eec8c194df" />
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="c8c46845-6722-4146-8f8f-1622c3cff276" >
<http:listener-connection host="0.0.0.0" port="8085" />
</http:listener-config>
<flow name="test_validationFlow" doc:id="e5f5e424-3f1e-4734-a2e7-3dd3a85f5c78" >
<http:listener doc:name="Listener" doc:id="7829b2dd-3969-42ea-a975-3ac50e3baf45" config-ref="HTTP_Listener_config" path="/ip"/>
<validation:is-ip doc:name="Is IP" doc:id="d813e66b-5e53-4b23-95f7-ae3974736210" config-ref="Validation_Config" ip="#[payload]"/>
</flow>
<flow name="test_validationFlow1" doc:id="1640488e-b554-41c8-a066-0b8137716eae" >
<http:listener doc:name="Listener" doc:id="6b6e3da0-b689-460a-bdaa-d2aa37e62f3b" config-ref="HTTP_Listener_config" path="/null"/>
<validation:is-null doc:name="Is null" doc:id="78444248-aa9b-4fbc-932a-33b33af8d620" value="#[payload]" config-ref="Validation_Config"/>
</flow>
</mule>
You might like this:
No comments:
Post a Comment