mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 18:29:40 +02:00
Validate contact and invoice emails when they change #2745
This commit is contained in:
parent
c482a3e46d
commit
6ca53f946a
7 changed files with 43 additions and 2 deletions
|
@ -19,6 +19,7 @@ class Contact < ActiveRecord::Base
|
|||
# Phone nr validation is very minimam in order to support legacy requirements
|
||||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/
|
||||
validates :email, format: /@/
|
||||
validates :email, email_format: { message: :invalid }, if: proc { |c| c.email_changed? }
|
||||
validates :ident,
|
||||
format: { with: /\d{4}-\d{2}-\d{2}/, message: :invalid_birthday_format },
|
||||
if: proc { |c| c.ident_type == 'birthday' }
|
||||
|
|
|
@ -12,7 +12,7 @@ class Invoice < ActiveRecord::Base
|
|||
}
|
||||
|
||||
attr_accessor :billing_email
|
||||
validates :billing_email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }, allow_blank: true
|
||||
validates :billing_email, email_format: { message: :invalid }, allow_blank: true
|
||||
|
||||
validates :invoice_type, :due_date, :currency, :seller_name,
|
||||
:seller_iban, :buyer_name, :invoice_items, :vat_prc, presence: true
|
||||
|
|
|
@ -45,7 +45,9 @@ class Registrar < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
validates :email, :billing_email, format: /@/, allow_blank: true
|
||||
validates :email, :billing_email,
|
||||
email_format: { message: :invalid },
|
||||
allow_blank: true, if: proc { |c| c.email_changed? }
|
||||
|
||||
WHOIS_TRIGGERS = %w(name email phone street city state zip)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue