mirror of
https://github.com/internetee/registry.git
synced 2025-05-21 19:59:38 +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
|
# Phone nr validation is very minimam in order to support legacy requirements
|
||||||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/
|
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/
|
||||||
validates :email, format: /@/
|
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 :ident_country_code, presence: true, if: proc { |c| %w(bic priv).include? c.ident_type }
|
||||||
validates :code, uniqueness: { message: :epp_id_taken }
|
validates :code, uniqueness: { message: :epp_id_taken }
|
||||||
validate :ident_valid_format?
|
validate :ident_valid_format?
|
||||||
|
@ -80,7 +82,7 @@ class Contact < ActiveRecord::Base
|
||||||
case ident_country_code
|
case ident_country_code
|
||||||
when 'EE'
|
when 'EE'
|
||||||
code = Isikukood.new(ident)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,7 +71,8 @@ class Epp::Contact < Contact
|
||||||
[:phone, :invalid],
|
[:phone, :invalid],
|
||||||
[:email, :invalid],
|
[:email, :invalid],
|
||||||
[:ident, :invalid],
|
[:ident, :invalid],
|
||||||
[:ident, :not_valid_EE_identity_format]
|
[:ident, :invalid_EE_identity_format],
|
||||||
|
[:ident, :invalid_birthday_format]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,12 +30,12 @@
|
||||||
%th{class: 'col-xs-2'}
|
%th{class: 'col-xs-2'}
|
||||||
= sort_link(@q, 'code', t(:code))
|
= sort_link(@q, 'code', t(:code))
|
||||||
%tbody
|
%tbody
|
||||||
- @contacts.each do |x|
|
- @contacts.each do |contact|
|
||||||
%tr
|
%tr
|
||||||
%td= link_to(x, admin_contact_path(x))
|
%td= link_to(contact, admin_contact_path(contact))
|
||||||
%td= x.ident
|
%td= "#{contact.ident} #{ident_indicator(contact)}"
|
||||||
%td= x.email
|
%td= contact.email
|
||||||
%td= x.code
|
%td= contact.code
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= paginate @contacts
|
= paginate @contacts
|
||||||
|
|
|
@ -45,7 +45,8 @@ en:
|
||||||
invalid: "Email is invalid"
|
invalid: "Email is invalid"
|
||||||
ident:
|
ident:
|
||||||
blank: "Required parameter missing - 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:
|
domains:
|
||||||
exist: 'Object association prohibits operation'
|
exist: 'Object association prohibits operation'
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,8 @@ describe Contact do
|
||||||
invalid.each do |date|
|
invalid.each do |date|
|
||||||
@contact.ident = date
|
@contact.ident = date
|
||||||
@contact.valid?
|
@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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue