Story#111396470 - show special message on contact ident update

This commit is contained in:
Vladimir Krylov 2016-01-12 14:10:34 +02:00
parent 88cd9c9146
commit cb6601ce1d
3 changed files with 5 additions and 2 deletions

View file

@ -238,13 +238,14 @@ class Contact < ActiveRecord::Base
def ident_valid_format?
case ident_country_code
when 'EE'.freeze
err_msg = "invalid_EE_identity_format#{"__update" if id}".to_sym
case ident_type
when 'priv'.freeze
errors.add(:ident, :invalid_EE_identity_format) unless Isikukood.new(ident).valid?
errors.add(:ident, err_msg) unless Isikukood.new(ident).valid?
when 'org'.freeze
# !%w(1 7 8 9).freeze.include?(ident.first) ||
if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/)
errors.add(:ident, :invalid_EE_identity_format)
errors.add(:ident, err_msg)
end
end
end

View file

@ -123,6 +123,7 @@ class Epp::Contact < Contact
[:email, :invalid],
[:ident, :invalid],
[:ident, :invalid_EE_identity_format],
[:ident, :invalid_EE_identity_format_update],
[:ident, :invalid_birthday_format],
[:ident, :invalid_country_code],
[:ident_type, :missing],

View file

@ -49,6 +49,7 @@ en:
ident:
blank: "Required parameter missing - ident"
invalid_EE_identity_format: "Ident not in valid Estonian identity format."
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"
domains: