Class: DailyAffirmation::Validators::DateValidator

Inherits:
DailyAffirmation::Validator show all
Defined in:
lib/daily_affirmation/validators/date_validator.rb

Overview

This affirmation ensures an attribute is a date and if a :before or :after option is given, that the attribute is before or after the selected date.

Defined Under Namespace

Classes: NullDateLike

Instance Method Summary collapse

Methods inherited from DailyAffirmation::Validator

#affirm, #initialize

Constructor Details

This class inherits a constructor from DailyAffirmation::Validator

Instance Method Details

#error_messageObject



23
24
25
26
27
# File 'lib/daily_affirmation/validators/date_validator.rb', line 23

def error_message
  @error_message ||= i18n_error_message(
    :format, :default => "#{attribute} is not a valid #{as}"
  )
end

#valid?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/daily_affirmation/validators/date_validator.rb', line 19

def valid?
  @valid ||= parseable? && before? && after?
end