This documentation is for WSO2 Data Services Server 3.0.0. View documentation for the latest release.

Validators Demo

This service uses validators in places where the validity of the input parameters has to be checked. This is shown in the "addEmployeeQuery" operation, by having a length validator for the "lastName" field where the length of the value should be between 3 and 20. Also, the "email" field is validated using a pattern validator which uses a regular expression to check if it's a real email address.

Follow the steps below to demonstrate this functionality:

1. Run the "addEmployee" operation with the parameters, employeeNumber=6001; lastName=AB; firstName=Nick; email=test@test.com; salary=1500. After running the operation, run the "employeesByNumber" operation with the parameter employeeNumber=6001. Note that you are not getting any results. The reason is because, the earlier "addEmployee" operation has failed due to a validation failure. The lastName was 2 characters long.

2. Run the "addEmployee" with parameters, employeeNumber=6001; lastName=ABC; firstName=Nick; email=test-test.com; salary=1500. In this case also, the entry will not be added because the email address is not valid.

3. Run the "addEmployee" with parameters, employeeNumber=6001; lastName=ABC; firstName=Nick; email=test@test.com; salary=1500. Here the entry will be successfully added and you will get a result as follows:


Copyright © WSO2 Inc. 2005-2013