Skip to main content
Version: 1.7.0

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:

  1. expected: which is what is expected by the route to work. In the example, the field was left undefined where we wanted a string.
  2. actual: is the actual given value.
  3. type: the validation error's type: here the field is required.
  4. field: the field where the error occurred.
  5. message: A unique message for this kind of validation errors that you can use in your frontend. Here validation_required will always be used when the field is required. And this message will always means that a field was left empty (undefined or null).

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:

TypeMessage
arrayvalidation_array
arrayEmptyvalidation_array_empty
arrayMin / arrayMaxvalidation_array_min / validation_array_max
arrayLengthvalidation_array_length
arrayEnumvalidation_array_enum
booleanvalidation_boolean
ExternalIdsArrayShouldMatchDataArrayErrorexternal_ids_array_should_match_data_array_error
FilePropertyErrorfile_property_error
FirstLastMandatoryDiscoveryErrorfirst_last_mandatory_discovery_error
emailvalidation_email
InvalidFileErrorinvalid_file_error
ModeOrIdShouldBeUsedErrormode_or_id_should_be_used_error
numbervalidation_number
numberMin / numberMaxvalidation_number_min / validation_number_max
requiredvalidation_required
SearchNotFoundErrorsearch_not_found_error
stringvalidation_string
stringEmptyvalidation_string_empty
stringEnumvalidation_string_enum