demarches-normaliennes/app/models/invite.rb

14 lines
360 B
Ruby
Raw Normal View History

2018-03-06 13:44:29 +01:00
class Invite < ApplicationRecord
include EmailSanitizableConcern
belongs_to :dossier
belongs_to :user
before_validation -> { sanitize_email(:email) }
2018-03-06 13:44:29 +01:00
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