title: Java 303 / 349 start date before end date validation
body: <p>Is there a better way of writing a Java validator which ensures that a start date is before an end date than writing a class level ConstraintValidator in the  following manner:</p>
  
  <pre><code>// VALIDATOR IMPLEMENTATION
  
      public class StartBeforeEndDateValidator implements ConstraintValidator&lt;StartBeforeEndDateValid, Object&gt; {
  
          // cannot use LocalDate here...
          private String start;
          private String end;
  
          @Override
          public void initialize(final StartBeforeEndDateValid annotation) {
              start = annotation.start();
              end = annotation.end();
  
          }
  
          @Override
          public boolean isValid(final Object bean, final ConstraintValidatorContext context) {
              try {
                  final String startDateStr = BeanUtils.getProperty(bean, start);
                  final String endDateStr = BeanUtils.getProperty(bean, end);
  
                  final LocalDate startDate = new LocalDate(startDateStr);
                  final LocalDate endDate = new LocalDate(endDateStr);
  
                  return !startDate.isAfter(endDate);
              } catch (final Exception e) {
                  return false;
              }
          }
      }
  
  
  // USAGE
      @StartBeforeEndDateValid(start = "startDate", end = "endDate")
      @Entity
      public class MyBean {
  
          @NotNull
          @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
          private LocalDate startDate;
  
          @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
          private LocalDate endDate;
  
          ... 
      }
  </code></pre>
  
  <p>I don't really like the fact that I have to use reflection to extract the 2 date objects from the bean. Unfortunately afaik the validation spec does not specify a way to set only the values you want to validate from the bean.</p>