Input validation

  • When a validation error is encountered, the api will return the status code 400 and in the body it will detail for each field the shared error encountered.
  • Each endpoint may have errors other than generic errors. These will be explained at each endpoint.
  • The error text in errorMessage will only be used for debugging and will not be displayed to the user. It is the programmer's duty to display specific error texts depending on the context / language, etc.
  • Errors that have the extra attribute will also contain an errorExtraValue key that will contain the referenced value.

Output example

[
{
"errorField": "uaTos",
"errorCode": 1,
"errorMessage": "The field is required."
},
{
"errorField": "uaPrivacy",
"errorCode": 8,
"errorMessage": "The field can not exceed 1 characters in length.",
"errorExtraValue": 1
},
{
"errorCode": 99,
"errorMessage": "Something went wrong."
}
]
CodeNameMessageValidation
1requiredThe field is required.No
2issetThe field must be present.No
3valid_emailThe field must contain a valid email address.No
4valid_emailsThe field must contain all valid email addresses.No
5valid_urlThe field must contain a valid URL.No
6valid_ipThe field must contain a valid IPv4 address.No
7min_lengthThe field must be at least %% characters in length.Yes
8max_lengthThe field can not exceed %% characters in length.Yes
9exact_lengthThe field field must be exactly %% characters in length.Yes
10alphaThe field may only contain alphabetical characters.No
11alpha_numericThe field may only contain alpha-numeric characters.No
13numericThe field must contain only numbers.No
14is_numericThe field must contain only numeric characters.No
15integerThe field must contain an integer.No
16regex_matchThe field is not in the correct format.No
17matchesThe field does not match the %% field.Yes
18is_uniqueThe field must contain a unique value.No
19is_naturalThe field must contain only positive numbers.No
20is_natural_no_zeroThe field must contain a number greater than zero.No
21decimalThe field must contain a decimal number.No
22less_thanThe field must contain a number less than %%.Yes
23greater_thanThe field must contain a number greater than %%.Yes
24rfc_dateThe field must contain a valid date. Ex: 2018-06-22No
25rfc_datetimeThe field must contain a valid time. Ex: 2018-06-22 23:44:02No
26valuesThe field must contain a one of the following values: %%.Yes
27valid_phoneThe field must contain a valid phone number. (+4012345789)No
28is_absentThe field must be absent.No
29invalid_valueThe field must be one of the allowed values.No
99genericGeneric error. No ideea what happened.No