-
-
Notifications
You must be signed in to change notification settings - Fork 203
Add separate fields for validation errors #7
Comments
Trying to add a unique field type that already exists in a collection can throw one multiple errors. Ex: trying to add a primary key and sort field to a collection that already have them. |
Maybe this is cleaner One error {
"error": {
"code": 123,
"message": ""
}
} Multiple errors (eg validation) {
"error": [
{
"code": 123,
"message": ""
},
{
"code": 123,
"message": ""
},
{
"code": 123,
"message": ""
}
]
} |
From #7 In an error like: {code: 4, message: "hidden: This value should not be blank."} It's quite hard to get the field ( {
"code": 4,
"message": "hidden: this value should not be blank",
"field": "hidden"
} That way, I can use them to translate the error messages dynamically |
@wellingguzman what's the status of this one? Do we need to discuss further? |
@benhaynes still in the discussing state. We need to really figuring out how we are formatting the attributes. We agreed on the Originally suggested to add a new property named Another suggestion I think may be better is adding an Something like this: {
"error": [
{
"code": 200,
"message": "name: this value should not be blank",
"attributes": {
"field": "name"
}
},
{
"code": 201,
"message": "age: this value should be numeric",
"attributes": {
"field": "age"
}
}
]
} Example: the error code will means: In this case you should expect any error ranging from This is my suggestion, Happy to discuss this further. |
That makes sense to me! I'll defer to you two on this one's formatting. @rijkvanzanten – any thoughts on Welling's proposed approach? |
LGTM! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
To achieve better clarity/visibility, we are now tracking feature requests within the Feature Request project board. This issue being closed does not mean it's not being considered. |
The API can return more than one validation error on posting / updating items. For example: wrong datatype and too long.
In order to make the error more useful, we should change the
error
message structure to something like:The text was updated successfully, but these errors were encountered: