post https://api.oneschema.co/v1/validate-json-rows
Validate a JSON array of records with template column keys and values. Errors and corresponding OneSchema error codes are returned in the response as JSON.
For example, given the following example Contacts template:
Column key | Date type | Validations |
---|---|---|
first_name | Alphabetical | Must be mapped |
last_name | Alphabetical | Must be mapped |
date_of_birth | Date MM/DD/YYYY | |
id | Number | Unique |
The following request would result in the provided response:
// Example request
{
"template_key": "contacts",
"rows": [
{ "id": 1, "last_name": "Smith" },
{ "id": 2, "first_name": "Charlie", "last_name": "Johnson9", "date_of_birth": "May 10th" },
{ "id": 3, "first_name": "Mary", "last_name": "Goel" },
{ "id": 3, "first_name": "Audrey", "last_name": "Goel" },
{ "id": 4, "first_name": "Tom", "last_name": "Jackson", "phone_number": "555-555-5555" }
]
}
// Example 200 response
{
"error_rows": [
{
"index": 0,
"errors": {
"first_name": {
"code": 8000,
"message": "Template column must be mapped"
}
}
},
{
"index": 1,
"errors": {
"last_name": {
"code": 37,
"message": "Must be only letters"
},
"date_of_birth": {
"code": 3,
"message": "Must match MM/DD/YYYY date format"
}
}
},
{
"index": 2,
"errors": {
"id": {
"code": 1000,
"message": "Data is duplicate in unique column"
}
}
},
{
"index": 3,
"errors": {
"id": {
"code": 1000,
"message": "Data is duplicate in unique column"
}
}
},
{
"index": 4,
"errors": {
"phone_number": {
"code": 8001,
"message": "Invalid template column"
}
}
}
]
}