return User.class.isAssignableFrom(aClass);
}
public void validate(Object obj, Errors errors) {
logger.debug("Validator called");
User user = (User) obj;
//check if the password is null or empty
if (StringUtils.isBlank(user.getPassword())) {
errors.rejectValue("password", "password.required");
logger.info("Password required");
}
//check if the password length is less than 4
else if (user.getPassword().length() < 4) {
errors.rejectValue("password", "password.invalid.length");
logger.info("Password must be at least 4 characters long");
}
//check if the confirm password is null or empty
if (StringUtils.isBlank(user.getConfirmPassword())) {
errors.rejectValue("confirmPassword", "confirmPassword.required");
logger.info("Confirm Password required");
}
//check if the confirm password matches the previous entered password
if (user.getConfirmPassword() != null && !(user.getConfirmPassword().equals(user.getPassword()))) {
errors.rejectValue("confirmPassword", "confirmPassword.mismatch");
logger.info("Password mismatch");
}
validateEmail(errors, user);