Skip to content

Commit

Permalink
Ajoute la validation sur le modèle Individual
Browse files Browse the repository at this point in the history
  • Loading branch information
kara22 committed Aug 19, 2024
1 parent 61525b6 commit 88cd4a9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/individual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Individual < ApplicationRecord
on: :update

validates :email, strict_email: true, presence: true, if: -> { dossier.for_tiers? && self.email? }, on: :update
validate :email_different_from_mandataire, on: :update

after_commit -> { dossier.index_search_terms_later }, if: -> { nom_previously_changed? || prenom_previously_changed? }

Expand All @@ -31,4 +32,10 @@ def self.from_france_connect(fc_information)
end

def unverified_email? = !email_verified_at?

def email_different_from_mandataire
if email.present? && email.casecmp?(dossier.user.email)
errors.add(:email, :must_be_different_from_mandataire)
end
end
end

0 comments on commit 88cd4a9

Please sign in to comment.