Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

raimdev
Copy link

@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
@@ -298,6 +300,17 @@ private PoulpeUser getPoulpeUser(String username) throws NotFoundException {
@Override
public void registration(PoulpeUser user) throws ValidationException {
List<String> errors = new ArrayList<String>();

BindingResult validateErrors = new BeanPropertyBindingResult(user, "user");
Copy link
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
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
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
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
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