From f1a2f9e7f4d28e79dd7a86b0f094186d9a57caac Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 27 May 2016 12:56:47 +0300 Subject: [PATCH] 114677695-hostname_puny_validation --- app/models/nameserver.rb | 5 +++-- config/locales/en.yml | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/nameserver.rb b/app/models/nameserver.rb index 4b6ef3df5..ee6684d12 100644 --- a/app/models/nameserver.rb +++ b/app/models/nameserver.rb @@ -28,6 +28,7 @@ class Nameserver < ActiveRecord::Base ], '2005' => [ [:hostname, :invalid, { value: { obj: 'hostAttr', val: hostname } }], + [:hostname_puny, :puny_to_long, { value: { obj: 'hostAttr', val: hostname } }], [:ipv4, :invalid, { value: { obj: 'hostAddr', val: ipv4 } }], [:ipv6, :invalid, { value: { obj: 'hostAddr', val: ipv6 } }] ], @@ -44,8 +45,8 @@ class Nameserver < ActiveRecord::Base end def check_label_length - hostname.split('.').each do |label| - errors.add(:hostname, :invalid) if label.length > 63 + hostname_puny.split('.').each do |label| + errors.add(:hostname_puny, :puny_to_long) if label.length > 63 end end diff --git a/config/locales/en.yml b/config/locales/en.yml index de5891c77..b90f62bc0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -131,6 +131,8 @@ en: hostname: invalid: 'Hostname is invalid' taken: 'Nameserver already exists on this domain' + hostname_puny: + puny_to_long: 'Hostname puny is too long (maximum is 63 characters)' ipv4: blank: 'IPv4 is missing' invalid: 'IPv4 is invalid'