mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Fix some validations
This commit is contained in:
parent
b351c97647
commit
79bfa3049e
1 changed files with 9 additions and 6 deletions
|
@ -105,9 +105,10 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
def validate_nameservers_uniqueness
|
||||
validated = []
|
||||
nameservers.reject(&:marked_for_destruction?).each do |ns|
|
||||
list = nameservers.reject(&:marked_for_destruction?)
|
||||
list.each do |ns|
|
||||
next if ns.hostname.blank?
|
||||
existing = nameservers.reject(&:marked_for_destruction?).select { |x| x.hostname == ns.hostname }
|
||||
existing = list.select { |x| x.hostname == ns.hostname }
|
||||
next unless existing.length > 1
|
||||
validated << ns.hostname
|
||||
errors.add(:nameservers, :invalid) if errors[:nameservers].blank?
|
||||
|
@ -147,9 +148,10 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
def validate_domain_statuses_uniqueness
|
||||
validated = []
|
||||
domain_statuses.reject(&:marked_for_destruction?).each do |status|
|
||||
list = domain_statuses.reject(&:marked_for_destruction?)
|
||||
list.each do |status|
|
||||
next if status.value.blank?
|
||||
existing = domain_statuses.select { |x| x.value == status.value }
|
||||
existing = list.select { |x| x.value == status.value }
|
||||
next unless existing.length > 1
|
||||
validated << status.value
|
||||
errors.add(:domain_statuses, :invalid) if errors[:domain_statuses].blank?
|
||||
|
@ -159,9 +161,10 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
def validate_dnskeys_uniqueness
|
||||
validated = []
|
||||
dnskeys.reject(&:marked_for_destruction?).each do |dnskey|
|
||||
list = dnskeys.reject(&:marked_for_destruction?)
|
||||
list.each do |dnskey|
|
||||
next if dnskey.public_key.blank?
|
||||
existing = dnskeys.select { |x| x.public_key == dnskey.public_key }
|
||||
existing = list.select { |x| x.public_key == dnskey.public_key }
|
||||
next unless existing.length > 1
|
||||
validated << dnskey.public_key
|
||||
errors.add(:dnskeys, :invalid) if errors[:dnskeys].blank?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue