Validation errors
Sometimes when using our API but when you do not supply the right information, you get validation errors. Here, you'll find all needed information to understand how they work and what they represent.
A validation has the following form:
{
"expected": "string",
"actual": undefined,
"type": "required",
"field": "user",
"message": "validation_required"
}
Each validation error has 5 fields:
expected
: which is what is expected by the route to work. In the example, the field was left undefined where we wanted astring
.actual
: is the actual given value.type
: the validation error's type: here the field isrequired
.field
: the field where the error occurred.message
: A unique message for this kind of validation errors that you can use in your frontend. Herevalidation_required
will always be used when the field is required. And this message will always means that a field was left empty (undefined
ornull
).
Response from routes
When the request body is not compliant with what is expected by the API, you'll receive all the validation errors in a response like this:
{
"success": false,
"validationErrors": [], // Array of validation errors
}
Validation errors used in the API
Here is the list of possible validation errors:
Type | Message |
---|---|
array | validation_array |
arrayEmpty | validation_array_empty |
arrayMin / arrayMax | validation_array_min / validation_array_max |
arrayLength | validation_array_length |
arrayEnum | validation_array_enum |
boolean | validation_boolean |
ExternalIdsArrayShouldMatchDataArrayError | external_ids_array_should_match_data_array_error |
FilePropertyError | file_property_error |
FirstLastMandatoryDiscoveryError | first_last_mandatory_discovery_error |
validation_email | |
InvalidFileError | invalid_file_error |
ModeOrIdShouldBeUsedError | mode_or_id_should_be_used_error |
number | validation_number |
numberMin / numberMax | validation_number_min / validation_number_max |
required | validation_required |
SearchNotFoundError | search_not_found_error |
string | validation_string |
stringEmpty | validation_string_empty |
stringEnum | validation_string_enum |