mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 18:29:40 +02:00
parent
3c4cba93f4
commit
d39d3766b2
9 changed files with 484 additions and 11 deletions
|
@ -141,7 +141,7 @@ class Domain < ActiveRecord::Base
|
|||
false
|
||||
end
|
||||
|
||||
validates :nameservers, object_count: {
|
||||
validates :nameservers, domain_nameserver: {
|
||||
min: -> { Setting.ns_min_count },
|
||||
max: -> { Setting.ns_max_count }
|
||||
}
|
||||
|
@ -692,6 +692,11 @@ class Domain < ActiveRecord::Base
|
|||
p_d = statuses.include?(DomainStatus::PENDING_DELETE)
|
||||
s_h = (statuses & [DomainStatus::SERVER_MANUAL_INZONE, DomainStatus::SERVER_HOLD]).empty?
|
||||
statuses << DomainStatus::SERVER_HOLD if p_d && s_h
|
||||
|
||||
if !self.class.nameserver_required?
|
||||
statuses << DomainStatus::INACTIVE if nameservers.empty?
|
||||
statuses.delete(DomainStatus::INACTIVE) if nameservers.size >= Setting.ns_min_count
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
|
|
|
@ -71,12 +71,6 @@ class Epp::Domain < Domain
|
|||
[:base, :required_parameter_missing_reserved]
|
||||
],
|
||||
'2004' => [ # Parameter value range error
|
||||
[:nameservers, :out_of_range,
|
||||
{
|
||||
min: Setting.ns_min_count,
|
||||
max: Setting.ns_max_count
|
||||
}
|
||||
],
|
||||
[:dnskeys, :out_of_range,
|
||||
{
|
||||
min: Setting.dnskeys_min_count,
|
||||
|
@ -124,7 +118,13 @@ class Epp::Domain < Domain
|
|||
[:registrant, :cannot_be_missing]
|
||||
],
|
||||
'2308' => [
|
||||
[:base, :domain_name_blocked, { value: { obj: 'name', val: name_dirty } }]
|
||||
[:base, :domain_name_blocked, { value: { obj: 'name', val: name_dirty } }],
|
||||
[:nameservers, :out_of_range,
|
||||
{
|
||||
min: Setting.ns_min_count,
|
||||
max: Setting.ns_max_count
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
||||
end
|
||||
|
|
12
app/validators/domain_nameserver_validator.rb
Normal file
12
app/validators/domain_nameserver_validator.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
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 if values.size.between?(min, max)
|
||||
association = options[:association] || attribute
|
||||
record.errors.add(association, :out_of_range, { min: min, max: max })
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue