Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SignUpValidator implements Validator {
- /**
- * If aClass equals User
- * @param aClass
- * @return
- */
- @Override
- public boolean supports(Class<?> aClass) {
- return User.class.equals(aClass);
- }
- @Override
- public void validate(Object o, Errors errors) {
- ValidationUtils.rejectIfEmptyOrWhitespace(errors,"phone","NO PHONE");
- User user = (User) o;
- /**
- * Check phone contains 10 digits
- */
- if (user.getPhone().length()!=10){
- errors.rejectValue("phone", "incorrect format");
- }
- }
- }
Add Comment
Please, Sign In to add comment