Class: MiniDefender::Rules::DateGte
- Inherits:
-
DateEq
show all
- Defined in:
- lib/mini_defender/rules/date_gte.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from DateEq
#initialize, make
#active?, available?, #bails?, #coerce, #default_value, #defaults?, #error_message, #excluded?, #force_coerce?, #implicit?, make, #priority, #stops?, #with_message
Class Method Details
.signature ⇒ Object
6
7
8
|
# File 'lib/mini_defender/rules/date_gte.rb', line 6
def self.signature
'date_gte'
end
|
Instance Method Details
#message(attribute, value, validator) ⇒ Object
19
20
21
22
23
|
# File 'lib/mini_defender/rules/date_gte.rb', line 19
def message(attribute, value, validator)
return "The given value is not a valid date." unless @valid_value
"The value must be greater than or equal to #{@target_date}."
end
|
#passes?(attribute, value, validator) ⇒ Boolean
10
11
12
13
14
15
16
17
|
# File 'lib/mini_defender/rules/date_gte.rb', line 10
def passes?(attribute, value, validator)
value = parse_date(value)
@valid_value = true
value >= @target_date
rescue ArgumentError
false
end
|