Normalize nameserver attributes before validation

This commit is contained in:
Martin Lensment 2014-10-20 12:26:36 +03:00
parent 9dbb098d6d
commit 081dc26632

View file

@ -37,6 +37,8 @@ class Domain < ActiveRecord::Base
delegate :phone, to: :owner_contact, prefix: true
delegate :name, to: :registrar, prefix: true
before_validation :downcase_attributes
before_create :generate_auth_info
before_create :set_validity_dates
after_create :attach_default_contacts
@ -70,6 +72,14 @@ class Domain < ActiveRecord::Base
self[:name_dirty] = value
end
def downcase_attributes
nameservers.each do |x|
x.hostname = x.hostname.try(:strip).try(:downcase)
x.ipv4 = x.ipv4.try(:strip)
x.ipv6 = x.ipv6.try(:strip).try(:upcase)
end
end
def owner_contact_typeahead
@owner_contact_typeahead || owner_contact.try(:name) || nil
end