class ActiveModel::Validations::HostnameValidator
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
Rules taken from www.zytrax.com/books/dns/apa/names.html
# File lib/validators/validates_hostname_format_of.rb, line 7 def validate_each(record, attribute, value) return if value.blank? && options[:allow_blank] return if value.nil? && options[:allow_nil] return if Validators::Hostname.valid?(value.to_s) record.errors.add( attribute, :invalid_hostname, message: options[:message], value: value ) end