From 0cdcb5299a967274989330f6278accee0eba557f Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 26 May 2016 18:23:22 +0300 Subject: [PATCH] 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]