@Test public void testValidate() { Comment obj = new Comment(); obj.setText("My Comment"); BindException errors = new BindException(obj, "comment"); new CommentValidator().validate(obj, errors); assertTrue(errors.getAllErrors().size() == 0); obj = new Comment(); errors = new BindException(obj, "comment"); new CommentValidator().validate(obj, errors); assertTrue(errors.getAllErrors().size() == 1); assertNotNull(errors.getFieldError("text")); }
@Override public void validate(Object obj, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "text", "error.required", "Text is required."); }
CommentValidator implements Validator { @Override public void validate(Object obj, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "text", "error.required", "Text is required."); } }
CommentValidator implements Validator { @Override public void validate(Object obj, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "text", "error.required", "Text is required."); }  }
CommentValidator implements Validator { @Override public void validate(Object obj, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "text", "error.required", "Text is required."); }  boolean supports(Class<?> clazz); @Override void validate(Object obj, Errors errors); }
CommentValidator implements Validator { @Override public void validate(Object obj, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "text", "error.required", "Text is required."); }  boolean supports(Class<?> clazz); @Override void validate(Object obj, Errors errors);  }