mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Story#109590460 - set business id validation
This commit is contained in:
parent
58bc4cc13b
commit
908a033b73
1 changed files with 10 additions and 6 deletions
|
@ -212,12 +212,16 @@ class Contact < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def ident_valid_format?
|
def ident_valid_format?
|
||||||
case ident_type
|
|
||||||
when 'priv'
|
|
||||||
case ident_country_code
|
case ident_country_code
|
||||||
when 'EE'
|
when 'EE'.freeze
|
||||||
code = Isikukood.new(ident)
|
case ident_type
|
||||||
errors.add(:ident, :invalid_EE_identity_format) unless code.valid?
|
when 'priv'.freeze
|
||||||
|
errors.add(:ident, :invalid_EE_identity_format) unless Isikukood.new(ident).valid?
|
||||||
|
when 'org'.freeze
|
||||||
|
last_char = ident.last
|
||||||
|
if ident.size != 8 || !%(1 8 9).freeze.include?(last_char) || ident !=~/\A[12][0-9]{6}[189]\z/
|
||||||
|
errors.add(:ident, :invalid_EE_identity_format)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue