mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
114677695-additional_validation_rule
This commit is contained in:
parent
b18021774d
commit
fa2231b27e
1 changed files with 6 additions and 0 deletions
|
@ -16,6 +16,7 @@ class Nameserver < ActiveRecord::Base
|
||||||
# rubocop: enable Metrics/LineLength
|
# rubocop: enable Metrics/LineLength
|
||||||
|
|
||||||
before_validation :normalize_attributes
|
before_validation :normalize_attributes
|
||||||
|
before_validation :check_puny_symbols
|
||||||
|
|
||||||
delegate :name, to: :domain, prefix: true
|
delegate :name, to: :domain, prefix: true
|
||||||
|
|
||||||
|
@ -41,6 +42,11 @@ class Nameserver < ActiveRecord::Base
|
||||||
self.ipv6 = Array(ipv6).reject(&:blank?).map(&:strip).map(&:upcase)
|
self.ipv6 = Array(ipv6).reject(&:blank?).map(&:strip).map(&:upcase)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_puny_symbols
|
||||||
|
regexp = /(\A|\.)..--/
|
||||||
|
errors.add(:hostname, :invalid) if hostname =~ regexp
|
||||||
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
hostname
|
hostname
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue