Skip to content

POULPE-529 FIX BUG: incorrect error while registration with empty username#9

Open
raimdev wants to merge 1 commit intojtalks-org:masterfrom
raimdev:POULPE-529
Open

POULPE-529 FIX BUG: incorrect error while registration with empty username#9
raimdev wants to merge 1 commit intojtalks-org:masterfrom
raimdev:POULPE-529

Conversation

@raimdev
Copy link
Copy Markdown

@raimdev raimdev commented Feb 20, 2016

Enabled spring validation for user object.

Enabled spring validation for user object.
@raimdev raimdev changed the title FIX BUG: incorrect error while registration with empty username POULPE-529 FIX BUG: incorrect error while registration with empty username Feb 20, 2016
public void registration(PoulpeUser user) throws ValidationException {
List<String> errors = new ArrayList<String>();

BindingResult validateErrors = new BeanPropertyBindingResult(user, "user");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @Valid should be enough if REST/MVC framework supports it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, now I try to write the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants