org.iscreen.validators
Class DateRangeValidator

java.lang.Object
  extended by org.iscreen.validators.DateRangeValidator
All Implemented Interfaces:
Validator

public class DateRangeValidator
extends java.lang.Object
implements Validator

The date range validator checks a "from" date to a "to" date to ensure that the "to" date is equal to or after the "from" date. If not, the "rangeFailure" is reported. In addition, a third check is done if the "date" property is mapped (not null), where if the "date" property is before the "from" date or after the "to" date, then the "betweenFailure" is reported. The mapping properties are: 'to', 'from' and 'date'.

Author:
Shellman, Dan

Nested Class Summary
protected  class DateRangeValidator.BeanToValidate
           
 
Constructor Summary
DateRangeValidator()
          Default constructor.
 
Method Summary
 java.lang.Object constructBeanToValidate()
          This is called prior to calling the validate() method.
 void setAfterFailure(FailureMessage failure)
           
 void setBeforeFailure(FailureMessage failure)
           
 void setRangeFailure(FailureMessage failure)
          This is the only failure that this validator reports.
 void validate(ValidatorContext context, java.lang.Object objectToValidate)
          This is the method that's called to validate the "bean-to-validate." Use the passed in ValidatorContext to report validation failures, etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateRangeValidator

public DateRangeValidator()
Default constructor.

Method Detail

validate

public void validate(ValidatorContext context,
                     java.lang.Object objectToValidate)
Description copied from interface: Validator
This is the method that's called to validate the "bean-to-validate." Use the passed in ValidatorContext to report validation failures, etc. The passed-in "bean-to-validate" is the same instance returned from the call to constructBeanToValidate(), but with all of the appropriate properties set (based upon the configured mapping).

Specified by:
validate in interface Validator
Parameters:
context - The ValidatorContext, which is used to report failures.
objectToValidate - The JavaBean to validate.

constructBeanToValidate

public java.lang.Object constructBeanToValidate()
Description copied from interface: Validator
This is called prior to calling the validate() method. This method is meant to construct a JavaBean that will have properties mapped to it for use by the validator.

Specified by:
constructBeanToValidate in interface Validator
Returns:
Returns a JavaBean that will have properties mapped to it for use by the call to the validate() method.

setRangeFailure

public void setRangeFailure(FailureMessage failure)
This is the only failure that this validator reports.

Parameters:
failure - The failure message to report.

setBeforeFailure

public void setBeforeFailure(FailureMessage failure)

setAfterFailure

public void setAfterFailure(FailureMessage failure)