feat(champs.validation): standardize champ error messages
This commit is contained in:
parent
4d90b1f662
commit
938f5043a4
4 changed files with 7 additions and 7 deletions
|
@ -6,13 +6,13 @@ class Champs::DecimalNumberChamp < Champ
|
||||||
allow_blank: true,
|
allow_blank: true,
|
||||||
message: -> (object, _data) {
|
message: -> (object, _data) {
|
||||||
# i18n-tasks-use t('errors.messages.not_a_float')
|
# i18n-tasks-use t('errors.messages.not_a_float')
|
||||||
"« #{object.libelle} » " + object.errors.generate_message(:value, :not_a_float)
|
object.errors.generate_message(:value, :not_a_float)
|
||||||
}
|
}
|
||||||
}, numericality: {
|
}, numericality: {
|
||||||
allow_nil: true,
|
allow_nil: true,
|
||||||
allow_blank: true,
|
allow_blank: true,
|
||||||
message: -> (object, _data) {
|
message: -> (object, _data) {
|
||||||
"« #{object.libelle} » " + object.errors.generate_message(:value, :not_a_number)
|
object.errors.generate_message(:value, :not_a_number)
|
||||||
}
|
}
|
||||||
}, if: -> { validate_champ_value? || validation_context == :prefill }
|
}, if: -> { validate_champ_value? || validation_context == :prefill }
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Champs::IntegerNumberChamp < Champ
|
||||||
allow_blank: true,
|
allow_blank: true,
|
||||||
message: -> (object, _data) {
|
message: -> (object, _data) {
|
||||||
# i18n-tasks-use t('errors.messages.not_an_integer')
|
# i18n-tasks-use t('errors.messages.not_an_integer')
|
||||||
"« #{object.libelle} » " + object.errors.generate_message(:value, :not_an_integer)
|
object.errors.generate_message(:value, :not_an_integer)
|
||||||
}
|
}
|
||||||
}, if: -> { validate_champ_value? || validation_context == :prefill }
|
}, if: -> { validate_champ_value? || validation_context == :prefill }
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe Champs::DecimalNumberChamp do
|
||||||
|
|
||||||
it 'is not valid and contains expected error' do
|
it 'is not valid and contains expected error' do
|
||||||
expect(subject).to be_falsey
|
expect(subject).to be_falsey
|
||||||
expect(champ.errors[:value]).to eq(["« #{champ.libelle} » doit comprendre maximum 3 chiffres après la virgule", "« #{champ.libelle} » n'est pas un nombre"])
|
expect(champ.errors[:value]).to eq(["doit comprendre maximum 3 chiffres après la virgule", "n'est pas un nombre"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ describe Champs::DecimalNumberChamp do
|
||||||
|
|
||||||
it 'is not valid and contains expected error' do
|
it 'is not valid and contains expected error' do
|
||||||
expect(subject).to be_falsey
|
expect(subject).to be_falsey
|
||||||
expect(champ.errors[:value]).to eq(["« #{champ.libelle} » doit comprendre maximum 3 chiffres après la virgule"])
|
expect(champ.errors[:value]).to eq(["doit comprendre maximum 3 chiffres après la virgule"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe Champs::IntegerNumberChamp do
|
||||||
|
|
||||||
it 'is not valid and contains errors' do
|
it 'is not valid and contains errors' do
|
||||||
is_expected.to be_falsey
|
is_expected.to be_falsey
|
||||||
expect(champ.errors[:value]).to eq(["« #{champ.libelle} » doit être un nombre entier (sans chiffres après la virgule)"])
|
expect(champ.errors[:value]).to eq(["doit être un nombre entier (sans chiffres après la virgule)"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ describe Champs::IntegerNumberChamp do
|
||||||
|
|
||||||
it 'is not valid and contains errors' do
|
it 'is not valid and contains errors' do
|
||||||
is_expected.to be_falsey
|
is_expected.to be_falsey
|
||||||
expect(champ.errors[:value]).to eq(["« #{champ.libelle} » doit être un nombre entier (sans chiffres après la virgule)"])
|
expect(champ.errors[:value]).to eq(["doit être un nombre entier (sans chiffres après la virgule)"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue