Class: MiniDefender::Rules::Timezone
Class Method Summary
collapse
Instance Method Summary
collapse
#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/timezone.rb', line 6
def self.signature
'timezone'
end
|
Instance Method Details
#message(attribute, value, validator) ⇒ Object
16
17
18
|
# File 'lib/mini_defender/rules/timezone.rb', line 16
def message(attribute, value, validator)
'The field should contain a valid time zone value.'
end
|
#passes?(attribute, value, validator) ⇒ Boolean
10
11
12
13
14
|
# File 'lib/mini_defender/rules/timezone.rb', line 10
def passes?(attribute, value, validator)
value.is_a?(String) && !!TZInfo::Timezone.get(value)
rescue TZInfo::InvalidTimezoneIdentifier
false
end
|