fix(cojo): fetch external data when "-01" suffix is typed, even if its deleted later by .to_i

This commit is contained in:
Colin Darie 2024-07-09 12:48:53 +02:00
parent 76a8e71fd5
commit 142ed6f762
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4

View file

@ -50,7 +50,7 @@ class Champs::COJOChamp < Champ
def update_external_id
if accreditation_number_changed? || accreditation_birthdate_changed?
if accreditation_number.present? && accreditation_birthdate.present? && /\A\d+\z/.match?(accreditation_number)
if accreditation_number.present? && accreditation_birthdate.present? && /\A[\d-]+\z/.match?(accreditation_number)
self.external_id = { accreditation_number:, accreditation_birthdate: }.to_json
else
self.external_id = nil