fix(tdc.expression_reguliere): invalid regexp shows nice error message
This commit is contained in:
parent
29d36973ba
commit
19268345db
4 changed files with 12 additions and 1 deletions
|
@ -4,7 +4,11 @@ class TypesDeChamp::ExpressionReguliereValidator < ActiveModel::EachValidator
|
|||
.flat_map { _1.repetition? ? procedure.draft_revision.children_of(_1) : _1 }
|
||||
.each do |tdc|
|
||||
if tdc.expression_reguliere? && tdc.invalid_regexp?
|
||||
procedure.errors.add(:expression_reguliere, type_de_champ: tdc)
|
||||
procedure.errors.add(
|
||||
attribute,
|
||||
procedure.errors.generate_message(attribute, :expression_reguliere_invalid, { value: tdc.libelle }),
|
||||
type_de_champ: tdc
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -76,12 +76,14 @@ en:
|
|||
empty_repetition: 'requires at least one field'
|
||||
empty_drop_down: 'requires at least one option'
|
||||
inconsistent_header_section: "%{custom_message}"
|
||||
expression_reguliere_invalid: "is invalid"
|
||||
draft_types_de_champ_private:
|
||||
format: 'Private field %{message}'
|
||||
invalid_condition: "have an invalid logic"
|
||||
empty_repetition: 'requires at least one field'
|
||||
empty_drop_down: 'requires at least one option'
|
||||
inconsistent_header_section: "%{custom_message}"
|
||||
expression_reguliere_invalid: "is invalid"
|
||||
attestation_template:
|
||||
format: "%{attribute} %{message}"
|
||||
initiated_mail:
|
||||
|
|
|
@ -82,12 +82,14 @@ fr:
|
|||
empty_repetition: 'doit comporter au moins un champ répétable'
|
||||
empty_drop_down: 'doit comporter au moins un choix sélectionnable'
|
||||
inconsistent_header_section: "%{custom_message}"
|
||||
expression_reguliere_invalid: "est invalide, veuillez la corriger"
|
||||
draft_types_de_champ_private:
|
||||
format: 'L’annotation privée %{message}'
|
||||
invalid_condition: "a une logique conditionnelle invalide"
|
||||
empty_repetition: 'doit comporter au moins un champ répétable'
|
||||
empty_drop_down: 'doit comporter au moins un choix sélectionnable'
|
||||
inconsistent_header_section: "%{custom_message}"
|
||||
expression_reguliere_invalid: "est invalide, veuillez la corriger"
|
||||
attestation_template:
|
||||
format: "%{attribute} %{message}"
|
||||
initiated_mail:
|
||||
|
|
|
@ -71,6 +71,9 @@ describe Procedure::ErrorsSummary, type: :component do
|
|||
|
||||
expect(page).to have_selector("a", text: "header sections must have consistent order")
|
||||
expect(page).to have_content("devrait être précédé d'un titre de niveau 1")
|
||||
|
||||
expect(page).to have_selector("a", text: "regexp invalid")
|
||||
expect(page).to have_content("est invalide, veuillez la corriger")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue