mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
Merge branch 'contact_ident'
Conflicts: db/schema.rb
This commit is contained in:
commit
8a4b91c3b7
8 changed files with 45 additions and 6 deletions
|
@ -7,10 +7,17 @@ class Contact < ActiveRecord::Base
|
|||
validate :ident_must_be_valid
|
||||
validates :phone, format: { with: /\+\d{3}\.\d+/, message: "bad format" }
|
||||
|
||||
IDENT_TYPES = [
|
||||
"ico", #Company registry code (or similar)
|
||||
"op", #Estonian ID
|
||||
"passport", #Passport number
|
||||
"birthday" #Birthday date
|
||||
]
|
||||
|
||||
def ident_must_be_valid
|
||||
#TODO Ident can also be passport number or company registry code.
|
||||
#so have to make changes to validations (and doc/schema) accordingly
|
||||
return true unless ident.present?
|
||||
return true unless ident.present? && ident_type.present? && ident_type == "op"
|
||||
code = Isikukood.new(ident)
|
||||
errors.add(:ident, 'bad format') unless code.valid?
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue