mirror of
https://github.com/internetee/registry.git
synced 2025-05-21 11:49:40 +02:00
Contact got correct birthday and country code epp errors
This commit is contained in:
parent
61ee8ef9f5
commit
a8e43dd6cc
5 changed files with 15 additions and 10 deletions
|
@ -18,7 +18,9 @@ class Contact < ActiveRecord::Base
|
|||
# Phone nr validation is very minimam in order to support legacy requirements
|
||||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/
|
||||
validates :email, format: /@/
|
||||
validates :ident, format: /\d{4}-\d{2}-\d{2}/, if: proc { |c| c.ident_type == 'birthday' }
|
||||
validates :ident,
|
||||
format: { with: /\d{4}-\d{2}-\d{2}/, message: :invalid_birthday_format },
|
||||
if: proc { |c| c.ident_type == 'birthday' }
|
||||
validates :ident_country_code, presence: true, if: proc { |c| %w(bic priv).include? c.ident_type }
|
||||
validates :code, uniqueness: { message: :epp_id_taken }
|
||||
validate :ident_valid_format?
|
||||
|
@ -80,7 +82,7 @@ class Contact < ActiveRecord::Base
|
|||
case ident_country_code
|
||||
when 'EE'
|
||||
code = Isikukood.new(ident)
|
||||
errors.add(:ident, :not_valid_EE_identity_format) unless code.valid?
|
||||
errors.add(:ident, :invalid_EE_identity_format) unless code.valid?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -71,7 +71,8 @@ class Epp::Contact < Contact
|
|||
[:phone, :invalid],
|
||||
[:email, :invalid],
|
||||
[:ident, :invalid],
|
||||
[:ident, :not_valid_EE_identity_format]
|
||||
[:ident, :invalid_EE_identity_format],
|
||||
[:ident, :invalid_birthday_format]
|
||||
]
|
||||
}
|
||||
end
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'code', t(:code))
|
||||
%tbody
|
||||
- @contacts.each do |x|
|
||||
- @contacts.each do |contact|
|
||||
%tr
|
||||
%td= link_to(x, admin_contact_path(x))
|
||||
%td= x.ident
|
||||
%td= x.email
|
||||
%td= x.code
|
||||
%td= link_to(contact, admin_contact_path(contact))
|
||||
%td= "#{contact.ident} #{ident_indicator(contact)}"
|
||||
%td= contact.email
|
||||
%td= contact.code
|
||||
.row
|
||||
.col-md-12
|
||||
= paginate @contacts
|
||||
|
|
|
@ -45,7 +45,8 @@ en:
|
|||
invalid: "Email is invalid"
|
||||
ident:
|
||||
blank: "Required parameter missing - ident"
|
||||
not_valid_EE_identity_format: "Ident not in valid Estonian identity format."
|
||||
invalid_EE_identity_format: "Ident not in valid Estonian identity format."
|
||||
invalid_birthday_format: "Ident not in valid birthady format, should be YYYY-MM-DD"
|
||||
domains:
|
||||
exist: 'Object association prohibits operation'
|
||||
|
||||
|
|
|
@ -149,7 +149,8 @@ describe Contact do
|
|||
invalid.each do |date|
|
||||
@contact.ident = date
|
||||
@contact.valid?
|
||||
@contact.errors.full_messages.should == ["Ident is invalid"]
|
||||
@contact.errors.full_messages.should ==
|
||||
["Ident Ident not in valid birthady format, should be YYYY-MM-DD"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue