Validate contact and invoice emails when they change #2745

This commit is contained in:
Priit Tark 2015-08-06 13:21:15 +03:00
parent c482a3e46d
commit 6ca53f946a
7 changed files with 43 additions and 2 deletions

View file

@ -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' }