Class: ActiveModel::Validations::HostnameValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::HostnameValidator
- Defined in:
- lib/validators/validates_hostname_format_of.rb
Instance Method Summary collapse
-
#validate_each(record, attribute, value) ⇒ Object
Rules taken from www.zytrax.com/books/dns/apa/names.html.
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
Rules taken from www.zytrax.com/books/dns/apa/names.html
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/validators/validates_hostname_format_of.rb', line 7 def validate_each(record, attribute, value) return if value.blank? && [:allow_blank] return if value.nil? && [:allow_nil] return if Validators::Hostname.valid?(value.to_s) record.errors.add( attribute, :invalid_hostname, message: [:message], value: value ) end |