How can I show validation messages after failed form submit? API request returns HTTP 400 'application/problem+json' response and contains violations as a list with field path.
https://tools.ietf.org/html/rfc7807#section-3
{
"type": "https://example.net/validation-error",
"title": "Your request parameters didn't validate.",
"invalid-params": [
{
"name": "age",
"reason": "must be a positive integer"
},
{
"name": "color",
"reason": "must be 'green', 'red' or 'blue'"
}
]
}
I have the solution for you, I'd recommend to do it with Saga and HttpError.
First, from our dataProvider we need to throw the
HttpError
like this:Then create saga like that:
Please make sure the errors (json) is in the format like in the example above!
Then insert the saga in the componenet:
Boom! it works
Good luck!