Validation rules

If the response from the API came with code = VALIDATION_FAILURE, then params will contain validation rules that did not pass the input data.

Response format:

{
    "status": "error",
    "response": {
        "code": 1,
        "name: "VALIDATION_FAILURE",
        "message": "Validation failure",
        "params": {
            "<param>": {
                "<rule>": [
                    "<value 1>",
                    "<value 2>",
                    "<value n>"
                ],
                ...
            },
            ...
        }
    }
}

where:

  • <param> - parameter name
  • <rule> - validation rule that failed
  • "<value 1>"-"<value n>" - validation rule parameters
Validation rule Rule Options Rule Description
Required - Required parameter
Sometimes - Optional parameter
Filled - The value must be filled. Used in conjunction with Sometimes
Numeric - The value must be numeric, including floating point. Decimal separator - dot
Integer - The value must be an integer. Used in conjunction with Numeric
Email - Value must be an email address
Url - The value must be a URL
Min
  • For numeric types, the value must be greater than the minimum value.
  • For string types - string length must be greater than the minimum
Minimum value
Max
  • For numeric types, the value must be less than the maximum value.
  • For string types - the length of the string must be less than the maximum
Maximum value
Unique
  • Table name
The passed value must be unique (not present in the table)
In
  • Values
The passed value must be in the list of valid values
Exists
  • Table name
  • Field name
The transferred value must be present in the table, in the specified field
Array - Value must be an array