mirror of
https://github.com/internetee/registry.git
synced 2025-08-01 23:42:04 +02:00
Basic ident and phone validations
This commit is contained in:
parent
256f564327
commit
1645b3e96f
6 changed files with 45 additions and 3 deletions
|
@ -1,7 +1,16 @@
|
|||
class Contact < ActiveRecord::Base
|
||||
#TODO Estonian id validation
|
||||
#TODO Foreign contact will get email with activation link/username/temp password
|
||||
#TODO Phone number validation, in first phase very minimam in order to support current registries
|
||||
has_many :addresses
|
||||
|
||||
validate :ident_must_be_valid
|
||||
validates :phone, format: { with: /\+\d{3}\.\d+/, message: "bad format" }
|
||||
|
||||
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?
|
||||
code = Isikukood.new(ident)
|
||||
errors.add(:ident, 'bad format') unless code.valid?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue