@Test public void testValidate03() { CustomerBirthdayValidator validator = new CustomerBirthdayValidator(); CustomerForm customer = new CustomerForm(); customer.setCustomerBirthYear(2012); customer.setCustomerBirthMonth(2); customer.setCustomerBirthDay(29); BindingResult result = new DirectFieldBindingResult(customer, "CustomerForm"); validator.validate(customer, result); assertThat(result.hasErrors(), is(false)); }
@Override public void validate(Object target, Errors errors) { CustomerForm customer = (CustomerForm) target; try { new DateTime(customer.getCustomerBirthYear(), customer .getCustomerBirthMonth(), customer .getCustomerBirthDay(), 0, 0).toDate(); } catch (IllegalArgumentException e) { errors.rejectValue("customerBirthYear", "IncorrectDate.customerBirth", "Incorrect date was entered."); } }
CustomerBirthdayValidator implements Validator { @Override public void validate(Object target, Errors errors) { CustomerForm customer = (CustomerForm) target; try { new DateTime(customer.getCustomerBirthYear(), customer .getCustomerBirthMonth(), customer .getCustomerBirthDay(), 0, 0).toDate(); } catch (IllegalArgumentException e) { errors.rejectValue("customerBirthYear", "IncorrectDate.customerBirth", "Incorrect date was entered."); } } }
CustomerBirthdayValidator implements Validator { @Override public void validate(Object target, Errors errors) { CustomerForm customer = (CustomerForm) target; try { new DateTime(customer.getCustomerBirthYear(), customer .getCustomerBirthMonth(), customer .getCustomerBirthDay(), 0, 0).toDate(); } catch (IllegalArgumentException e) { errors.rejectValue("customerBirthYear", "IncorrectDate.customerBirth", "Incorrect date was entered."); } }  }
CustomerBirthdayValidator implements Validator { @Override public void validate(Object target, Errors errors) { CustomerForm customer = (CustomerForm) target; try { new DateTime(customer.getCustomerBirthYear(), customer .getCustomerBirthMonth(), customer .getCustomerBirthDay(), 0, 0).toDate(); } catch (IllegalArgumentException e) { errors.rejectValue("customerBirthYear", "IncorrectDate.customerBirth", "Incorrect date was entered."); } }  @Override boolean supports(Class<?> clazz); @Override void validate(Object target, Errors errors); }
CustomerBirthdayValidator implements Validator { @Override public void validate(Object target, Errors errors) { CustomerForm customer = (CustomerForm) target; try { new DateTime(customer.getCustomerBirthYear(), customer .getCustomerBirthMonth(), customer .getCustomerBirthDay(), 0, 0).toDate(); } catch (IllegalArgumentException e) { errors.rejectValue("customerBirthYear", "IncorrectDate.customerBirth", "Incorrect date was entered."); } }  @Override boolean supports(Class<?> clazz); @Override void validate(Object target, Errors errors);  }