@Override public void validate(Object auth, Errors errors) { User user = (User) auth; List<User> users = userService.getUsersByEmail(user.getEmail()); if (users.size() > 0) { errors.rejectValue("email", "user.email.suchEmailAlreadyExists"); } }
@Override public void validate(Object auth, Errors errors) { User fUser = (User) auth; User pUser; try { pUser = userService.getUserByUsername(fUser.getUsername()); } catch (UsernameNotFoundException notFoundException) { pUser = null; } if (pUser != null) { errors.rejectValue("username", "user.username.suchLoginAlreadyExists"); } }