mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Merge pull request #144 from internetee/111601356-ident_type_validation
111601356 ident type validation
This commit is contained in:
commit
b161cfd40c
3 changed files with 12 additions and 0 deletions
|
@ -33,6 +33,8 @@ class Contact < ActiveRecord::Base
|
|||
uniqueness: { message: :epp_id_taken },
|
||||
format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid },
|
||||
length: { maximum: 100, message: :too_long_contact_code }
|
||||
|
||||
validate :val_ident_type
|
||||
validate :val_ident_valid_format?
|
||||
validate :uniq_statuses?
|
||||
validate :validate_html
|
||||
|
@ -241,6 +243,10 @@ class Contact < ActiveRecord::Base
|
|||
name || '[no name]'
|
||||
end
|
||||
|
||||
def val_ident_type
|
||||
errors.add(:ident_type, :epp_ident_type_invalid, code: code) if !%w(org priv birthday).include?(ident_type)
|
||||
end
|
||||
|
||||
def val_ident_valid_format?
|
||||
case ident_country_code
|
||||
when 'EE'.freeze
|
||||
|
|
|
@ -132,6 +132,9 @@ class Epp::Contact < Contact
|
|||
'2302' => [ # Object exists
|
||||
[:code, :epp_id_taken]
|
||||
],
|
||||
'2304' => [ # Object status prohibits operation
|
||||
[:ident_type, :epp_ident_type_invalid, { value: { obj: 'code', val: code}, interpolation: {code: code}}]
|
||||
],
|
||||
'2305' => [ # Association exists
|
||||
[:domains, :exist]
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue