Do not require name servers in registrar area

#267
This commit is contained in:
Artur Beljajev 2016-12-29 16:27:07 +02:00
parent ffd29f6a67
commit b9df5aa92d
11 changed files with 411 additions and 281 deletions

View file

@ -1,10 +1,10 @@
class DomainNameserverValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return true if !Domain.nameserver_required? && value.empty?
min, max = options[:min].call, options[:max].call
values = value.reject(&:marked_for_destruction?)
return true if !Domain.nameserver_required? && values.empty?
return if values.size.between?(min, max)
association = options[:association] || attribute
record.errors.add(association, :out_of_range, { min: min, max: max })