From fa2231b27e30129f4719d5a1e4dabe0a7b857341 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 24 May 2016 16:34:26 +0300 Subject: [PATCH] 114677695-additional_validation_rule --- app/models/nameserver.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/nameserver.rb b/app/models/nameserver.rb index 729ac6cbf..00a06c95f 100644 --- a/app/models/nameserver.rb +++ b/app/models/nameserver.rb @@ -16,6 +16,7 @@ class Nameserver < ActiveRecord::Base # rubocop: enable Metrics/LineLength before_validation :normalize_attributes + before_validation :check_puny_symbols delegate :name, to: :domain, prefix: true @@ -41,6 +42,11 @@ class Nameserver < ActiveRecord::Base self.ipv6 = Array(ipv6).reject(&:blank?).map(&:strip).map(&:upcase) end + def check_puny_symbols + regexp = /(\A|\.)..--/ + errors.add(:hostname, :invalid) if hostname =~ regexp + end + def to_s hostname end