Validаtion. VMS Billing API
Validation
An object with an error always has the same format.
{
"message": "There will be no informative message here",
"errors": {
"any_key": [
"The cause of the error will be described here"
]
}
}
The error data is contained within the errors
object. The keys inside errors
tell which field from the request the errors relate to. But there may be exceptions when the error does not relate to a specific field. There may be several errors.
Example
The url
field with the value http//example.com
is passed in the request.
This field is validated that it must be a URL address with maximum 10 characters.
And also the date
field with the value 2000-01-01
, and the validation that the date format should be Y-m-d H:i:s
Then the response will be the following object:
{
"message": "The given data was invalid",
"errors": {
"url" : [
"The url field is in an incorrect format.",
"The url field cannot be more than 20"
],
"date": [
"The date field does not match the format Y-m-d H:i:s."
]
}
}