Params Validation
object:
key | Type | Description |
---|---|---|
error | String | Always "Invalid parameters" |
details | Errors object | See Errors below |
details.(path.0.to.)parameter_name | Array ParameterError | See ParameterError below |
Example response
// Considering that request with following payload has been sent:
{
"member": { "first_name": "s", "msisdns": ["123", "4740769126",""] }
}
// Following response is returned:
{
"error": "Invalid parameters",
"details": {
"member": {
"name": [
{ "error": "too_short", "options": { "min_length": 0 } },
{ "error": "invalid_format", "options": { "format": "/[A-Z][a-z]+/" } }
],
"msisdns": {
"0": [{ "error": "invalid_msisdn" }],
"2": [{ "error": "blank" }]
}
}
}
}
// It means that in given payload:
// * member.name is too short
// * member.name has invalid format
// * member.msisdns[0] is not a valid MSISDN
// * member.msisdns[2] is blank
Errors object
Objects being parts of arrays are represented by their array indexes.
ParameterError object
Key | Type | Optional? | Description |
---|---|---|---|
error | String | no | Symbol of error that relates to this parameter |
options | Object | no | Contains options of specific validation rule. For example {"max": 15} . |
Common validation errors
Error key | Options | Description |
---|---|---|
attribute_cannot_be_present_with | with - other attribute name | Mutually exclusive with another attribute |
attribute_cannot_be_present_without | without - other attribute name | |
blank | When not present | |
greater_or_equal_to | number - min value | When not greater than or equal to number |
does_not_exist | When related record does not exist | |
invalid | format - regex | When has invalid format |
greater_than | number - min value | When not > number |
greater_than_property | property - compared property | When not > value of property |
inclusion | in - contains permitted values | When doesn't match list of permitted values |
invalid_car_registration_number | When doesn't match required car registration number format | |
invalid_date | When doesn't match date format ('YYYY:MM:DD') | |
invalid_hex_color | When doesn't match hex color format ('#000000') | |
invalid_hour | When doesn't match hour format ('HH:MM') | |
invalid_json | When isn't a valid JSON | |
invalid_msisdn | When cannot be processed as a valid MSISDN> | |
invalid_email | ||
invalid_iso_3166_country | When not valid ISO 3166-1 alpha-2 country code | |
invalid_iso_8601_time | When not valid according to ISO 8601 | |
invalid_iso_639_1_language | When not valid according to ISO 639-1 | |
less_or_equal_to | number - max value | When not less than or equal to number |
less_than | number - max value | When not < number |
less_than_property | property - compared property | When not > value of property |
liquid_syntax_error | syntax_error - error description | When not valid liquid syntax |
must_be_a_string | ||
must_be_a_boolean | ||
must_be_an_array | ||
must_be_an_url | allowed_protocols - e.g ['https'] | When not a valid URL |
must_be_a_https_url | When not a valid HTTPS URL | |
must_be_an_array_of_objects | ||
must_be_an_object | ||
must_be_in_the_future | When date is not in the future | |
must_be_in_the_past | When date is not in the past | |
must_be_unique | When value is not unique in some context | |
must_be_uuid | When not a valid UUID | |
must_have_elements_of_type | type - required type | |
not_a_number | ||
not_an_integer | ||
record_does_not_exist | When related record does not exist | |
records_do_not_exist | non_existing_ids | When related records do not exist |
size_not_match | number - exact size | When array has not exactly required number of elements |
size_too_large | number - max size | When array has too many elements |
size_too_small | number - min size | When array has not enough elements |
too_short | min - min length, count - given length | When string length is too small |
too_long | max - max length, count - given length | When string length is too large |
taken | When another record already uses this value | |
unpermitted_property |
Modified at 2024-09-25 08:23:52