Class: ActiveModel::Validations::ReservedHostnameValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::ReservedHostnameValidator
show all
- Defined in:
- lib/validators/validates_reserved_hostname.rb
Instance Method Summary
collapse
Instance Method Details
#reserved?(subdomain) ⇒ Boolean
19
20
21
|
# File 'lib/validators/validates_reserved_hostname.rb', line 19
def reserved?(subdomain)
::Validators::ReservedHostnames.reserved?(subdomain, options[:in])
end
|
#validate_each(record, attribute, value) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/validators/validates_reserved_hostname.rb', line 6
def validate_each(record, attribute, value)
return if value.blank? && options[:allow_blank]
return if value.nil? && options[:allow_nil]
return unless reserved?(value.to_s)
record.errors.add(
attribute,
:"reserved_#{options[:error_name]}",
message: options[:message],
value: value
)
end
|