use of won.owner.pojo.UserPojo in project webofneeds by researchstudio-sat.
the class UserRegisterValidator method validate.
@Override
public void validate(final Object target, final Errors errors) {
UserPojo user = (UserPojo) target;
validator.validate(target, errors);
if (user.getPassword().length() < 6) {
errors.rejectValue("password", "passwordTooShort", "Password needs to be at least 6 Characters long");
}
if (errors.getFieldError("username") != null) {
User userInDb = (User) wonUserDetailService.loadUserByUsername(user.getUsername());
if (userInDb != null) {
errors.reject("userIsAlreadyInDb", "Username already exists, please choose a different one");
}
}
}