Class DateValidator

java.lang.Object
com.jbstrap.core.validators.DateValidator
All Implemented Interfaces:
DataValidator

public class DateValidator extends Object implements DataValidator
Date validator class
Since:
4.0
Author:
JBStrap
  • Constructor Details

    • DateValidator

      public DateValidator()
      Creates a date validator object, with the default yyyy-MM-dd date format
    • DateValidator

      public DateValidator(String format)
      Creates a date validator, with the specified date format
      Parameters:
      format - The date format, that will be used for the validation process
  • Method Details

    • validateData

      public String validateData(Object data, String language)

      Validates the specified value.

      The specified value will be validated, if it can be converted into a date, according to the specified date format.

      The error message returned by the method can be customized, or can be translated, by using the validator.dateValidatorError properties file key. For more information about translating/multi-language support, see the MessageSourceAPI class description

      Specified by:
      validateData in interface DataValidator
      Parameters:
      data - The data to be validated
      language - The language code of the error message. If not specified, the default language will be used. The default language can be set with the DEFAULT_LANGUAGE JBStrap parameter.
      Returns:
      The specified error message or null, if the validation found no errors.