mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 01:33:36 +02:00
Validate e-mail when country is other than estonia
This commit is contained in:
parent
0dc0cc63d9
commit
42b1890bf5
4 changed files with 20 additions and 4 deletions
|
@ -12,8 +12,9 @@ class User < ActiveRecord::Base
|
|||
|
||||
validates :username, :password, presence: true
|
||||
validates :identity_code, uniqueness: true, allow_blank: true
|
||||
validates :identity_code, presence: true, if: -> { country.iso == 'EE' && identity_code.blank? }
|
||||
validates :registrar, presence: true, if: -> { !admin && !registrar }
|
||||
validates :identity_code, presence: true, if: -> { country.iso == 'EE' }
|
||||
validates :email, presence: true, if: -> { country.iso == 'LV' }
|
||||
validates :registrar, presence: true, if: -> { !admin }
|
||||
|
||||
before_save -> { self.registrar = nil if admin? }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue