POULPE-529 FIX BUG: incorrect error while registration with empty username#9
POULPE-529 FIX BUG: incorrect error while registration with empty username#9raimdev wants to merge 1 commit intojtalks-org:masterfrom raimdev:POULPE-529
Conversation
Enabled spring validation for user object.
| public void registration(PoulpeUser user) throws ValidationException { | ||
| List<String> errors = new ArrayList<String>(); | ||
|
|
||
| BindingResult validateErrors = new BeanPropertyBindingResult(user, "user"); |
There was a problem hiding this comment.
This kind of validation usually happens in the REST services. Often frameworks have integration with BeanValidation so that you don't need to invoke it yourself.
There was a problem hiding this comment.
if I understand correctly, it is sufficient use @Valid annotation and delete extra codes?
@Override
public void registration(@Valid PoulpeUser user) throws ValidationException {
I checked, it works, but still want to clarify
There was a problem hiding this comment.
Yes, @Valid should be enough if REST/MVC framework supports it.
There was a problem hiding this comment.
Would be awesome if you could write a test using Jersey Test Framework that checks if the validation is actually happening. You can use an in-memory container for that, read here for more details.
There was a problem hiding this comment.
Yes, now I try to write the test.
Enabled spring validation for user object.