It's pretty common (but not universal) to want to include error information on a per-field basis.
I'd like to propose that in addition to the `error` (singular) key, an `errors` key could be provided, which would include a number of errors, with the values being `error` objects formatted as already specified.
I would also like error to optionally be an Array of errors:
{ "collection" :
{
"version" : "1.0",
"errors" : {
{
"password": [{
"title": "Validation Error",
"code": "X422",
"message": "Must be at least 6 characters"
}, {
"title": "Validation Error",
"code": "X422",
"message": "Must contain at least one number"
}],
"name": {
"title": "Validation Error",
"code": "X422",
"message": "Must not be blank"
}
}
}
}
}
At present, the spec only allows one error, and makes all fields optional. I think we should specifically allow a string as the value of a message object, so the following would be semantically equivalent:
{ "collection" :
{
"version" : "1.0",
"errors" : {
"password": [
"Must have at least six characters",
"Must have a symbol"
],
"name": "Must not be blank"
}
}
}
and
{ "collection" :
{
"version" : "1.0",
"errors" : {
"password": [
{ "message": "Must have at least six characters" },
{ "message": "Must have a symbol" }
],
"name": { "message": "Must not be blank" }
}
}
}