Merge pull request #10757 from mfo/US/fix-required-dossier-link-with-missing-dossier

correct: ETQ administrateur, je souhaite que les types de champ liens vers un dossier pointent vers un dossier valide si ils sont obligatoire
This commit is contained in:
Colin Darie 2024-09-09 07:28:48 +00:00 committed by GitHub
commit 977e47fa74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 54 additions and 6 deletions

View file

@ -2,9 +2,16 @@
class Champs::DossierLinkChamp < Champ
validate :value_integerable, if: -> { value.present? }, on: :prefill
validate :dossier_exists, if: -> { validate_champ_value? && !value.nil? }
private
def dossier_exists
if mandatory? && !Dossier.exists?(value)
errors.add(:value, :not_found)
end
end
def value_integerable
Integer(value)
rescue ArgumentError