diff --git a/app/models/domain.rb b/app/models/domain.rb index ec632ffaa..2fa4387b3 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -33,7 +33,7 @@ class Domain < ActiveRecord::Base validates :owner_contact, presence: true validate :validate_period - validate :validate_nameservers_uniqueness + #validate :validate_nameservers_uniqueness def name=(value) value.strip! diff --git a/app/models/nameserver.rb b/app/models/nameserver.rb index c52ba6b1b..b08702a7c 100644 --- a/app/models/nameserver.rb +++ b/app/models/nameserver.rb @@ -2,7 +2,7 @@ class Nameserver < ActiveRecord::Base include EppErrors EPP_ATTR_MAP = { - hostname: 'hostName' + hostname: 'hostObj' } belongs_to :registrar @@ -12,8 +12,13 @@ class Nameserver < ActiveRecord::Base validates :ipv4, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_blank: true } validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true } + validates :hostname, uniqueness: { scope: :domain_id } + def epp_code_map { + '2302' => [ + [:hostname, :taken] + ], '2005' => [ [:hostname, :invalid], [:ipv4, :invalid], diff --git a/config/locales/en.yml b/config/locales/en.yml index 275431cb5..d93b6bdaa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -99,6 +99,7 @@ en: attributes: hostname: invalid: 'Hostname is invalid' + taken: 'Nameserver already exists on this domain' ipv4: invalid: 'IPv4 is invalid' ipv6: