mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
parent
ffd29f6a67
commit
b9df5aa92d
11 changed files with 411 additions and 281 deletions
|
@ -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 })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue