Class DateValidator

  • All Implemented Interfaces:
    Serializable, IComponentAwareEventSink, IComponentAwareHeaderContributor, org.apache.wicket.util.io.IClusterable, IValidator<Date>

    public class DateValidator
    extends RangeValidator<Date>
    Validator for checking if a given date falls within [min,max] range. If either min or max are null they are not checked.

    Resource keys:

    • DateValidator.exact if min==max
    • DateValidator.range if both min and max are not null
    • DateValidator.minimum if max is null
    • DateValidator.maximum if min is null

    Error Message Variables:

    • name: the id of Component that failed
    • label: the label of the Component (either comes from FormComponent.labelModel or resource key <form-id>.<form-component-id>
    • input: the input value
    • inputdate: the formatted input value
    • minimum: the minimum allowed value
    • maximum: the maximum allowed value

    Author:
    igor
    See Also:
    Serialized Form
    • Constructor Detail

      • DateValidator

        public DateValidator​(Date minimum,
                             Date maximum,
                             String format)
        Constructor that sets the minimum and maximum date values and a custom date formating.
        Parameters:
        minimum - the minimum date
        maximum - the maximum date
        format - The format string used to format the date with SimpleDateFormat
      • DateValidator

        public DateValidator​(Date minimum,
                             Date maximum)
        Constructor that sets the minimum and maximum date values.
        Parameters:
        minimum - the minimum date
        maximum - the maximum date
    • Method Detail

      • range

        public static DateValidator range​(Date minimum,
                                          Date maximum)
        Parameters:
        minimum - the minimum Date
        maximum - the maximum Date
        Returns:
        a DateValidator that validates if a date is between (inclusive) a minimum and maximum
      • range

        public static DateValidator range​(Date minimum,
                                          Date maximum,
                                          String format)
        Parameters:
        minimum - the minimum Date
        maximum - the maximum Date
        format - The format string used to format the date with SimpleDateFormat
        Returns:
        a DateValidator that validates if a date is between (inclusive) a minimum and maximum
      • minimum

        public static DateValidator minimum​(Date minimum)
        Parameters:
        minimum - the minimum Date
        Returns:
        a DateValidator that validates if a date is after or equal to a minimum date
      • minimum

        public static DateValidator minimum​(Date minimum,
                                            String format)
        Parameters:
        minimum - the minimum Date
        format - The format string used to format the date with SimpleDateFormat
        Returns:
        a DateValidator that validates if a date is after or equal to a minimum date
      • maximum

        public static DateValidator maximum​(Date maximum)
        Parameters:
        maximum - the maximum Date
        Returns:
        a DateValidator that validates if a date is before or equal to a maximum date
      • maximum

        public static DateValidator maximum​(Date maximum,
                                            String format)
        Parameters:
        maximum - the maximum Date
        format - The format string used to format the date with SimpleDateFormat
        Returns:
        a DateValidator that validates if a date is before or equal to a maximum date