[Fix #1479] Validate Avis email format

This commit is contained in:
Mathieu Magnin 2018-02-27 16:58:22 +01:00
parent 247526578c
commit 38e1609d73
3 changed files with 28 additions and 2 deletions

View file

@ -3,6 +3,8 @@ class Avis < ApplicationRecord
belongs_to :gestionnaire
belongs_to :claimant, class_name: 'Gestionnaire'
validates :email, format: { with: Devise.email_regexp, message: "n'est pas valide" }, allow_nil: true
before_save :clean_email
before_create :try_to_assign_gestionnaire
after_create :notify_gestionnaire