コード例 #1
0
  @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");
    }
  }
コード例 #2
0
  @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");
    }
  }