You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expect, similar to non-odata validation, informative message, with path, and some hint to where the problem is actually happening, for example:
{
"error": {
"code": "",
"message": "The input was not valid.\r\n\r\ncustomer:\r\nThe customer field is required.",
"details": [
{
"code": "",
"target": "customer.age",
"message": "The input was not valid."
},
{
"code": "",
"target": "customer",
"message": "The customer field is required."
}
]
}
}
important part here is : "target": "customer.age", , it indicates where exactly problem happening. It can be something else, similar to non-odata validation error message:
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-1fe2f2e1f3ead0709ff5e445e1dffdc9-c1c420ab67a12d0c-00",
"errors": {
"customer": [
"The customer field is required."
],
"$.age": [
"The JSON value could not be converted to System.Int32. Path: $.age | LineNumber: 3 | BytePositionInLine: 15."
]
}
}
Actual result
With OData enabled controllers, I got:
{
"error": {
"code": "",
"message": "The input was not valid.\r\n\r\ncustomer:\r\nThe customer field is required.",
"details": [
{
"code": "",
"message": "The input was not valid."
},
{
"code": "",
"target": "customer",
"message": "The customer field is required."
}
]
}
}
So, there no clue or hint that problem actually in the age property. In trivial models like presented it's relatively simple to understand what happened, but in case of complex models - it could be really challenging to figure out what is causing this.
Something similar to above
"$.age": [
"The JSON value could not be converted to System.Int32. Path: $.age | LineNumber: 3 | BytePositionInLine: 15."
]
Validation message is not informative in case of deserialization error.
Assemblies affected
Reproduce steps
Given simple model
and controller method with straight-forward validation like:
when sending non-valid data, like
Expected result
I expect, similar to non-odata validation, informative message, with path, and some hint to where the problem is actually happening, for example:
important part here is :
"target": "customer.age",
, it indicates where exactly problem happening. It can be something else, similar to non-odata validation error message:Actual result
With OData enabled controllers, I got:
So, there no clue or hint that problem actually in the
age
property. In trivial models like presented it's relatively simple to understand what happened, but in case of complex models - it could be really challenging to figure out what is causing this.Something similar to above
is expected, and would really help.
Full example https://github.com/pil0t/ODataValidation
The text was updated successfully, but these errors were encountered: