From 00a1d70bc579327db857e17c1cc173e8d51835e4 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 3 May 2016 15:52:43 +0300 Subject: [PATCH 1/6] 111601356-ident_type_validation --- app/models/contact.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/contact.rb b/app/models/contact.rb index 57174296a..d6d5369dd 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -33,6 +33,7 @@ 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 } + validates :ident_type, inclusion: {in: %w( org priv birthday)} validate :val_ident_valid_format? validate :uniq_statuses? validate :validate_html From 36a854ab4c02d46d8c8dc5dde4ba2b6894356320 Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 20 May 2016 16:30:33 +0300 Subject: [PATCH 2/6] =?UTF-8?q?11=D1=91601356-error=5Fmap=5Fupd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/epp/contact.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index df2dabf78..f6bf54f74 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -126,6 +126,7 @@ class Epp::Contact < Contact [:ident, :invalid_birthday_format], [:ident, :invalid_country_code], [:ident_type, :missing], + [:ident_type, :invalid], [:code, :invalid], [:code, :too_long_contact_code] ], From 7d1decbc87f1614664e1cf78e1271186174b21cb Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 24 May 2016 17:25:16 +0300 Subject: [PATCH 3/6] 111601356-extra_msg --- app/models/contact.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index d6d5369dd..edc7bedd3 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -33,7 +33,7 @@ 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 } - validates :ident_type, inclusion: {in: %w( org priv birthday)} + validates :ident_type, inclusion: {in: %w( org priv birthday), message: :invalid} validate :val_ident_valid_format? validate :uniq_statuses? validate :validate_html From 7a27756a36d41a625420867732487e7382cf9398 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 25 May 2016 12:42:10 +0300 Subject: [PATCH 4/6] 111601356-errors_customization --- app/models/contact.rb | 2 +- app/models/epp/contact.rb | 4 +++- config/locales/en.yml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index edc7bedd3..bdf0a6017 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -33,7 +33,7 @@ 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 } - validates :ident_type, inclusion: {in: %w( org priv birthday), message: :invalid} + validates :ident_type, inclusion: {in: %w( org priv birthday), message: :ident_type_invalid} validate :val_ident_valid_format? validate :uniq_statuses? validate :validate_html diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index f6bf54f74..af3cc13a9 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -126,13 +126,15 @@ class Epp::Contact < Contact [:ident, :invalid_birthday_format], [:ident, :invalid_country_code], [:ident_type, :missing], - [:ident_type, :invalid], [:code, :invalid], [:code, :too_long_contact_code] ], '2302' => [ # Object exists [:code, :epp_id_taken] ], + '2304' => [ + [:ident_type, :invalid, { value: { obj: 'ident_type', val: ident_type } }] + ], '2305' => [ # Association exists [:domains, :exist] ], diff --git a/config/locales/en.yml b/config/locales/en.yml index de5891c77..ea05adec3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -266,6 +266,7 @@ en: unimplemented_command: 'Unimplemented command' domain_exists_but_belongs_to_other_registrar: 'Domain exists but belongs to other registrar' required_ident_attribute_missing: "Required ident attribute missing: %{key}" + ident_type_invalid: 'Ident type is invalid' code: 'Code' value: 'Value' From 9e3bb02dd169b6e42362d935070c823df8607856 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 25 May 2016 17:19:50 +0300 Subject: [PATCH 5/6] 111601356-error_text_modification --- app/models/epp/contact.rb | 4 ++-- config/locales/en.yml | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index af3cc13a9..8e1da8e4b 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -132,8 +132,8 @@ class Epp::Contact < Contact '2302' => [ # Object exists [:code, :epp_id_taken] ], - '2304' => [ - [:ident_type, :invalid, { value: { obj: 'ident_type', val: ident_type } }] + '2304' => [ # Object status prohibits operation + [:ident_type, :epp_ident_type_invalid, { value: { obj: 'code', val: code } }] ], '2305' => [ # Association exists [:domains, :exist] diff --git a/config/locales/en.yml b/config/locales/en.yml index ea05adec3..4e915de6a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -52,6 +52,9 @@ en: invalid_EE_identity_format_update: "Ident not in valid Estonian identity format. Please create new contact" invalid_birthday_format: "Ident not in valid birthady format, should be YYYY-MM-DD" invalid_country_code: "Ident country code is not valid, should be in ISO_3166-1 alpha 2 format" + ident_type: + ident_type_invalid: 'Ident type is invalid' + epp_ident_type_invalid: 'Object status prohibits operation: ident_type of contact %{code} is invalid' domains: exist: 'Object association prohibits operation' statuses: @@ -266,7 +269,6 @@ en: unimplemented_command: 'Unimplemented command' domain_exists_but_belongs_to_other_registrar: 'Domain exists but belongs to other registrar' required_ident_attribute_missing: "Required ident attribute missing: %{key}" - ident_type_invalid: 'Ident type is invalid' code: 'Code' value: 'Value' From 0cdcb5299a967274989330f6278accee0eba557f Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 26 May 2016 18:23:22 +0300 Subject: [PATCH 6/6] 111601356-validation_change --- app/models/contact.rb | 7 ++++++- app/models/epp/contact.rb | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index bdf0a6017..94a8d0818 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -33,7 +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 } - validates :ident_type, inclusion: {in: %w( org priv birthday), message: :ident_type_invalid} + + validate :val_ident_type validate :val_ident_valid_format? validate :uniq_statuses? validate :validate_html @@ -241,6 +242,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 diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 8e1da8e4b..bddee18ab 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -133,7 +133,7 @@ class Epp::Contact < Contact [:code, :epp_id_taken] ], '2304' => [ # Object status prohibits operation - [:ident_type, :epp_ident_type_invalid, { value: { obj: 'code', val: code } }] + [:ident_type, :epp_ident_type_invalid, { value: { obj: 'code', val: code}, interpolation: {code: code}}] ], '2305' => [ # Association exists [:domains, :exist]