mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
Contact CRUD in admin section
This commit is contained in:
parent
d6543f2148
commit
c644a297e1
6 changed files with 149 additions and 7 deletions
|
@ -19,6 +19,7 @@ class Contact < ActiveRecord::Base
|
|||
validates :code, :phone, :email, :ident, presence: true
|
||||
|
||||
validate :ident_must_be_valid
|
||||
validate :presence_of_one_address
|
||||
|
||||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ # /\+\d{3}\.\d+/
|
||||
validates :email, format: /@/
|
||||
|
@ -50,6 +51,12 @@ class Contact < ActiveRecord::Base
|
|||
end
|
||||
##
|
||||
|
||||
def presence_of_one_address
|
||||
return true if local_address || international_address
|
||||
errors.add(:local_address, 'Local or international address must be present')
|
||||
errors.add(:international_address, 'Local or international address must be present')
|
||||
end
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue