| 13 | } |
| 14 | |
| 15 | @Override |
| 16 | public void validate(Object target, Errors errors) { |
| 17 | System.out.println("LocalValidator.validate() is called"); |
| 18 | |
| 19 | User user = (User)target; |
| 20 | |
| 21 | String id = user.getId(); |
| 22 | |
| 23 | // if(id==null || "".equals(id.trim())) { |
| 24 | // errors.rejectValue("id", "required"); |
| 25 | // } |
| 26 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "id", "required"); |
| 27 | ValidationUtils.rejectIfEmptyOrWhitespace(errors, "pwd", "required"); |
| 28 | |
| 29 | if(id==null || id.length() < 5 || id.length() > 12) { |
| 30 | errors.rejectValue("id", "invalidLength"); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |