diff --git a/app/models/contact.rb b/app/models/contact.rb index 12afbe777..a4f6e5029 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -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 diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index df2dabf78..bddee18ab 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -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] ], diff --git a/config/locales/en.yml b/config/locales/en.yml index d3f2b8cbe..400985d16 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: