Step 1: Create a Validation pipeline
Create a Validation pipeline named βUserName_Acc_customers_validationβ and define it as follows:
To go to the Validation pipeline, on the left side panel, click βValidation pipelineβ under the βData managementβ menu.

To create a new validation, click on the [+ Validation pipeline] button.

The Details tab is selected by default. To define the Validation pipeline:
Enter Validation Name as βUserName_Acc_customers_validationβ.
Optionally enter a description for this Validation pipeline.
To define a target entity for this Validation pipeline, select the target entity from the drop-down menu as βUserName_Acc_customersβ.

To create a new Step, go to the Code tab and expand the Validation steps function.

To create a new step, click on the [+ Step] button.

A new Step is created with the label βDescriptionβ.

To give the Step a more meaningful name, click the text βDescriptionβ and rename it to βcheck for mandatory fieldsβ. This Step is defined to check that the values for the mandatory fields: First Name, Last Name, Email, and Phone are entered.

To add Criteria bars in the step, click the (+) button. Add four (4) Criteria bars.

To check if the value of the βFirst_Nameβ field is not set, define the first Criteria bar as follows:
Select Source as Variables>Source_UserName_Acc_customers>First_Name. It is displayed as βSource_UserName_Acc_customers.First_Nameβ.
Select Operator as βIs Not Setβ.

To check if the value of the βLast_Nameβ field is not set, define the second Criteria bar:
Select Source as Variables>Source_UserName_Acc_customers>Last_Name. It is displayed as βSource_UserName_Acc_customers.Last_Nameβ.
Select Operator as βIs Not Setβ.

When two Criteria bars are defined, they are grouped together by the AND operator. To add a third Criteria bar to the AND group, ensure to click the (+) immediately below the second Criteria bar.

To check if the value of the βEmailβ field is not set, define the third Criteria bar:
Select Source as Variables>Source_UserName_Acc_customers>Email. It is displayed as βSource_UserName_Acc_customers.Emailβ.
Select Operator as βIs Not Setβ.

To check if the value of the βPhoneβ field is not set, define the fourth Criteria bar:
Select Source as Variables>Source_UserName_Acc_customers>Phone. It is displayed as βSource_UserName_Acc_customers.Phoneβ.
Select Operator as βIs Not Setβ.

To check if the values entered are just empty strings, add four (4) more Criteria bars.
To check if the value of the βFirst_Nameβ field is empty, define the fifth Criteria bar:
Select Source as Variables>Source_UserName_Acc_customers>First_Name. It is displayed as βSource_UserName_Acc_customers.First_Nameβ.
Select Operator as βIs Emptyβ.

To check if the value of the βLast_Nameβ field is empty, define the sixth Criteria bar:
Select Source as Variables>Source_UserName_Acc_customers>Last_Name. It is displayed as βSource_UserName_Acc_customers.Last_Nameβ.
Select Operator as βIs Emptyβ.

To check if the value of the βEmailβ field is empty, define the seventh Criteria bar:
Select Source as Variables>Source_UserName_Acc_customers>Email . It is displayed as βSource_UserName_Acc_customers.Emailβ.
Select Operator as βIs Emptyβ.

To check if the value of the βPhoneβ field is empty, define the eighth Criteria bar:
Select Source as Variables>Source_UserName_Acc_customers>Phone. It is displayed as βSource_UserName_Acc_customers.Phoneβ.
Select Operator as βIs Emptyβ.

Finally click on the logical operator βANDβ to make it βORβ. This means if any of these Criteria bars are not valid or empty, proceed to the actions.

To define Actions, go to the Code tab>On True section of Step 1. Add four (4) Actions by clicking the (+) button. If the criteria is validated to True, a sequence of actions in the βOn Trueβ section will be executed. In this case, the error response will be returned if the criteria is valid and any of the fields is not present or contains empty strings. Here, the details of the response are configured in case of βOn Trueβ.

To define the first Action to update the errorcode in the Response as β400β:
Select Action as βUpdate Variableβ.
Select Target variable as Response>errorcode. It displays as βResponse.errorcodeβ.
In the Value, type the number as β400β and press Enter.

To define the second action to update the message in the βResponseβ:
Select Action as βUpdate Variableβ.
Select Target variable as Response>message. It displays as βResponse.messageβ.
In the Value, type the text as βComplete mandatory fields: First Name, Last Name, Email and Phone.β and press enter.

To define the third action to update the status of the βResponseβ:
Select Action as βUpdate Variableβ.
Select the Target variable as Response>status. It displays as βResponse.statusβ.
In the Value, type the text as βMissing mandatory field(s)β and press Enter.

Add the last Action in the section as βExit Validationβ that exits with the value βfalseβ. Based on the value of True or False, the On Validation step success or On Validation step fail function in the Validation>Code tab is executed.
Select Action as βExit Validationβ.
In the βExit Withβ field, type βfalseβ and press Enter.

To check if the phone number is valid, add Step 2 and label it as βcheck if phone number is validβ. This Step will verify if the phone number entered is numeric and the length is between 7 and 10 digits.

To verify the phone number data type, minimum length and maximum length, add three (3) Criteria bars by clicking the (+) button in the βCriteriaβ tab.

To verify if the phone number is of numeric value, define the first Criteria bar as follows:
Select Source as Source_UserName_Acc_customers>Phone>isNumeric(). It is displayed as βSource_UserName_Acc_customers.Phone.isNumeric()β.
Select Operator as βIs Equalβ.
Enter the Value as βtrueβ.

To verify if the phone number length is less than or equal to 10, define the second Criteria bar as follows:
Select Source as Source_UserName_Acc_customers>Phone>length(). It is displayed as βSource_UserName_Acc_customers.Phone.length()β. This measures the length of the strings entered into the field.
Select Operator as βLess Than Equal toβ.
Enter the Integer value as β10β.

To verify if the phone number length is greater than 7, define the third Criteria bar as follows:
Select Source as Source_UserName_Acc_customers>Phone>length(). It is displayed as βSource_UserName_Acc_customers.Phone.length()β. This measures the length of the strings entered into the field.
Select Operator as βGreater Thanβ.
Enter the Integer value as β7β.

Keep AND as the logical operator. This means all of the Criteria bars must return true before executing the Code tab>On True section. If any of the Criteria bars does not return true, the Code tab>On False section Actions will be executed. The Criteria tab should be as per the image below.

To define the actions if the Criteria returns true, go to the Code tab>On True section of βStep 2β to define the sequence of actions. Add an Action by clicking the (+) button.

To exit validation if the Criteria returns true, define the action as follows:
Select Action as βExit Validationβ.
In the βExit Withβ field, type βtrueβ and press Enter. Based on the value of the Exit Validation as true, the Validation>Code tab>On Validation step success section is executed followed by the execution of the βOn Exitβ section. If no Action in the On Validation step success section of Validation>Code tab is configured, only the βOn Exitβ section is executed.

To define the response details in case invalid customer phone data is encountered, go to the Code tab>On False section. Add three (3) Actions by clicking the (+) button.

To define the response message, define the first action to update the message in the Response.
Select Action as βUpdate Variableβ.
Select Target Variable as Response>message. It displays as βResponse.messageβ.
In the Value, type the text as βPhone number provided is invalid.β and press Enter.

To define the response status, define the second action to update the status of the βResponseβ as βinvalid dataβ .
Select Action as βUpdate Variableβ.
Select Target Variable as Response>status. It displays as βResponse.statusβ.
In the Value, type the text as βinvalid dataβ and press Enter.

To define the response error code, define the third action to update the errorcode in the βResponseβ as β401β.
Select Action as βUpdate Variableβ.
Select Target Variable as Response>errorcode. It displays as βResponse.errorcodeβ.
In the Value, type the number as β401β and press Enter.

Add the last action in the section to define βExit Validationβ action as βfalseβ. Based on the βfalseβ value, the βOn Validation step failβ section of the Validation>Code tab is executed.
Select Action as βExit Validationβ.
In the Exit With field, type βfalseβ and press Enter.

To save the Validation pipeline, click the [Save] button.

To publish the Validation pipeline, click the [Publish] button.

Last updated
