/* (non-Javadoc)
* @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
public void validate(Object clazz, Errors e) {
PasswordReset obj = (PasswordReset) clazz;
ValidationUtils.rejectIfEmptyOrWhitespace(e, "emailAddress", "error.required", new Object[]{"Email Address"});
if (!StringUtil.isEmpty(obj.getEmailAddress()) && !coreUserDAO.isRegisteredByEmail(obj.getEmailAddress())) {
e.rejectValue("emailAddress","msg.email-address-is-not-registered",
"Sorry, but your email address is not registered.");
}
ValidationUtils.rejectIfEmptyOrWhitespace(e, "password", "error.required", new Object[]{"Password"});
ValidationUtils.rejectIfEmptyOrWhitespace(e, "confirmPassword", "error.required", new Object[]{"Confirm Password"});
if (!StringUtil.isEmpty(obj.getPassword()) && (obj.getPassword().length()<6)) {
e.reject("err.your-password-should-be-at-least-6-characters-long","Your password should be at least 6 characters long.");
}
if (!StringUtil.isEmpty(obj.getPassword()) && !StringUtil.isEmpty(obj.getConfirmPassword()) &&
!obj.getPassword().equals(obj.getConfirmPassword()) ) {
e.reject("err.your-password-confirmation-did-not-match-with-password",
"Your password confirmation did not match with password.");
}
}