demarches-normaliennes/app/models/invite.rb
2018-03-14 17:41:45 +01:00

13 lines
360 B
Ruby

class Invite < ApplicationRecord
include EmailSanitizableConcern
belongs_to :dossier
belongs_to :user
before_validation -> { sanitize_email(:email) }
validates :email, presence: true
validates :email, uniqueness: { scope: :dossier_id }
validates :email, format: { with: Devise.email_regexp, message: "n'est pas valide" }, allow_nil: true
end