mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 08:22:05 +02:00
Domain reservation validation
This commit is contained in:
parent
fb12d056ce
commit
f87c8839be
6 changed files with 36 additions and 6 deletions
|
@ -8,9 +8,8 @@ class Domain < ActiveRecord::Base
|
|||
belongs_to :technical_contact, class_name: 'Contact'
|
||||
belongs_to :admin_contact, class_name: 'Contact'
|
||||
|
||||
validates :name, domain_name: true
|
||||
validates :name, domain_name: true, uniqueness: true
|
||||
validates :name_puny, domain_name: true
|
||||
validates :name_dirty, uniqueness: true
|
||||
|
||||
def name=(value)
|
||||
value.strip!
|
||||
|
@ -25,11 +24,16 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
res = []
|
||||
domains.each do |x|
|
||||
if !DomainNameValidator.validate(x)
|
||||
if !DomainNameValidator.validate_format(x)
|
||||
res << {name: x, avail: 0, reason: 'invalid format'}
|
||||
next
|
||||
end
|
||||
|
||||
if !DomainNameValidator.validate_reservation(x)
|
||||
res << {name: x, avail: 0, reason: 'Domain name is reserved or restricted'}
|
||||
next
|
||||
end
|
||||
|
||||
if Domain.find_by(name: x)
|
||||
res << {name: x, avail: 0, reason: 'in use'} #confirm reason with current API
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue