-
Notifications
You must be signed in to change notification settings - Fork 565
Description
Willie Wheeler opened DATAREST-700 and commented
I have a custom validator that I've registered through RepositoryRestConfigurerAdapter.configureValidatingRepositoryEventListener()
. Validation is working.
However only validation errors generated by errors.rejectValue(...)
show up in the SDR JSON response. So e.g. this works as expected:
errors.rejectValue(
"company",
"customer.active.companyNotNull",
"Active customer must have a defined company.");
I.e., it generates
{
"errors": [{
"entity":"Customer",
"message":"Active customer must have a defined company.",
"invalidValue":"null",
"property":"company"
}]
}
If on the other hand I do errors.reject(...)
to generate a global error, it doesn't appear in the response. E.g.,
errors.reject(
"customer.active.companyNotNull",
"Active customers must have a defined company.");
generates
{ errors: [0] }
even though validation has actually failed. I do get the HTTP 400 and I do see my validation failure log messages on the console.
Leaving aside the question of whether I ought to be using a field error or a global error here, it seems that global errors should still show up in the output.
Affects: 2.4 GA (Gosling)
2 votes, 3 watchers