Comment on page
Server Side Validation
Validate data at your server, report back errors for correction.
Consider a case where you want to validate the incoming data against your business rules. This could be as simple as verifying if the user ID is found in the database or something more complex that involves custom logic. Here you want the validation to be done at your server end and relay back errors if any.
With CSVbox you have the option of server-side validation of the submitted data and returning back the errors. Then the users can fix the errors and re-submit the data.
Server Side Validation
Go to Edit Sheet > Select Destination Tab > Enable Server Side Validation

Activate Server Side Validation
The users upload the spreadsheet, map columns, verify data, and then submit.
The importer will send the spreadsheet data via POST requests with JSON values to your API endpoint. The request schema is available here.
Case 1: Validation is successful - no errors found. Your API returns a
200
HTTP response code. The success screen is displayed to the user.
Success Screen
Case 2: Validation failed - one or more errors found. Your API returns
211
HTTP response code along with the validation errors in JSON format. The error response JSON format is mentioned here.It is mandatory for your API to return
211
HTTP response status code to instruct the CSVbox importer that there are one or more server-side validation errors.To view the results screen be sure to configure the CSVbox Result Page Settings. Go to Sheet Settings > Display > Results Page > Set Closing the import dialog box to Do not close on import complete

If there are one or more server-side validation errors then the users will see the Fail Screen with a button to view the errors.

Fail Screen with View Errors Button
Clicking on the Errors button will take the users to the Verify Data screen with all the server-side errors displayed in yellow color.

Validation Errors in Yellow Color
Only the rows having the errors will be displayed.
On re-submitting the data, the process will repeat. The importer will push the data to your API endpoint via POST requests and look for errors in the response.
Each re-submit will be treated as a fresh import having a new
Import_Id
.To allow the users to re-submit all the rows again (instead of error rows only) select the 'All Rows' option as shown below:

Re-submit All Rows
CSVbox will expect the API endpoint to return an array of errors. Each error should specify the
row_id
, the column
the error appeared in, and a message
to be displayed in the UI.Parameter | Type | Description |
---|---|---|
row_id | integer | The row number of the error. Starts with 1. |
column | string | |
message | string | The message to be displayed to the user on the validation screen of the importer. |
[
{
"row_id": 1,
"column": "employee_id",
"message": "Invalid Emp ID"
},
{
"row_id": 2,
"column": "dept",
"message": "Department does not exist"
},
{
"row_id": 3,
"column": "employee_name",
"message": "Employee's name has changed"
}
]
Last modified 8d ago