diff --git a/app/models/champs/engagement_juridique_champ.rb b/app/models/champs/engagement_juridique_champ.rb index 903365e8d..9fb24114e 100644 --- a/app/models/champs/engagement_juridique_champ.rb +++ b/app/models/champs/engagement_juridique_champ.rb @@ -3,5 +3,5 @@ class Champs::EngagementJuridiqueChamp < Champ validates_with ExpressionReguliereValidator, expression_reguliere: /([A-Z]|[0-9]|\-|\_|\+|\/)+/, expression_reguliere_error_message: "Le numéro d'EJ ne peut contenir que des caractères alphanumérique et les caractères spéciaux suivant : “-“ ; “_“ ; “+“ ; “/“", - if: -> { validation_context != :brouillon } + if: :validate_champ_value? end diff --git a/spec/models/engagement_juridique_champ_spec.rb b/spec/models/engagement_juridique_champ_spec.rb index 7d5306fae..f704fa237 100644 --- a/spec/models/engagement_juridique_champ_spec.rb +++ b/spec/models/engagement_juridique_champ_spec.rb @@ -1,7 +1,7 @@ describe Champs::EngagementJuridiqueChamp do describe 'validation' do let(:champ) { build(:champ_engagement_juridique, value: value) } - subject { champ.valid? } + subject { champ.validate(:champs_public_value) } context 'with [A-Z]' do let(:value) { "ABC" }