Class: MiniDefender::Rules::Date

Inherits:
MiniDefender::Rule show all
Defined in:
lib/mini_defender/rules/date.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MiniDefender::Rule

#active?, available?, #bails?, #coerce, #default_value, #defaults?, #error_message, #excluded?, #force_coerce?, #implicit?, make, #priority, #stops?, #with_message

Class Method Details

.signatureObject



6
7
8
# File 'lib/mini_defender/rules/date.rb', line 6

def self.signature
  'date'
end

Instance Method Details

#message(attribute, value, validator) ⇒ Object



16
17
18
# File 'lib/mini_defender/rules/date.rb', line 16

def message(attribute, value, validator)
  'The given value is not a valid date.'
end

#passes?(attribute, value, validator) ⇒ Boolean

Returns:



10
11
12
13
14
# File 'lib/mini_defender/rules/date.rb', line 10

def passes?(attribute, value, validator)
  parse_date(value).is_a?(Time)
rescue ArgumentError
  false
end