Class: MiniDefender::Rules::Hostname
Constant Summary
collapse
- HOSTNAME_REGEX =
/\A[a-zA-Z0-9][a-zA-Z0-9\-]{1,63}(\.[a-zA-Z0-9][a-zA-Z0-9\-]{1,63})+\.?\z/
Class Method Summary
collapse
Instance Method Summary
collapse
#active?, available?, #bails?, #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/hostname.rb', line 6
def self.signature
'hostname'
end
|
Instance Method Details
#coerce(value) ⇒ Object
10
11
12
|
# File 'lib/mini_defender/rules/hostname.rb', line 10
def coerce(value)
value.to_s.downcase.strip
end
|
#message(attribute, value, validator) ⇒ Object
21
22
23
|
# File 'lib/mini_defender/rules/hostname.rb', line 21
def message(attribute, value, validator)
'Invalid hostname.'
end
|
#passes?(attribute, value, validator) ⇒ Boolean
14
15
16
17
18
19
|
# File 'lib/mini_defender/rules/hostname.rb', line 14
def passes?(attribute, value, validator)
value = value.to_s.downcase.strip
return false if value.length > 255
value.match?(HOSTNAME_REGEX)
end
|