Browse Source

feat: include person_num in error text

pull/2197/head
natdeanlewissoftwire 2 years ago
parent
commit
f38ebb3c0b
  1. 4
      app/models/validations/sales/household_validations.rb
  2. 2
      config/locales/en.yml

4
app/models/validations/sales/household_validations.rb

@ -38,8 +38,8 @@ private
return unless age && relationship return unless age && relationship
if age < 16 && !relationship_is_child_other_or_refused?(relationship) if age < 16 && !relationship_is_child_other_or_refused?(relationship)
record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_relat_sales") record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_relat_sales", person_num:)
record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_under_16_sales") record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_under_16_sales", person_num:)
elsif age >= 20 && person_is_child?(relationship) elsif age >= 20 && person_is_child?(relationship)
record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_20") record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_20")
record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_over_20") record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_over_20")

2
config/locales/en.yml

@ -452,7 +452,7 @@ en:
retired_over_70: "Answer cannot be over 70 as person %{person_num} has economic status that is not ‘retired’" retired_over_70: "Answer cannot be over 70 as person %{person_num} has economic status that is not ‘retired’"
child_under_16_relat_lettings: "Answer cannot be under 16 as person %{person_num}'s relationship to the lead tenant is not ‘child’, ‘other’ or ‘prefers not to say’" child_under_16_relat_lettings: "Answer cannot be under 16 as person %{person_num}'s relationship to the lead tenant is not ‘child’, ‘other’ or ‘prefers not to say’"
child_under_16_relat_sales: "Answer cannot be under 16 as person %{person_num}'s relationship to buyer 1 is not ‘child’, ‘other’ or ‘prefers not to say’" child_under_16_relat_sales: "Answer cannot be under 16 as person %{person_num}'s relationship to buyer 1 is not ‘child’, ‘other’ or ‘prefers not to say’"
child_under_16_ecstat: "Answer cannot be under 16 as person’s %{person_num} working situation is not ‘child under 16’, ‘other’ or ‘prefers not to say’" child_under_16_ecstat: "Answer cannot be under 16 as person %{person_num}’s working situation is not ‘child under 16’, ‘other’ or ‘prefers not to say’"
child_over_16: "Answer cannot be over 16 as person’s %{person_num} working situation is ‘child under 16‘" child_over_16: "Answer cannot be over 16 as person’s %{person_num} working situation is ‘child under 16‘"
child_over_20: "Answer cannot be 20 or over as the relationship is ‘child’" child_over_20: "Answer cannot be 20 or over as the relationship is ‘child’"
child_12_years_younger: "A child must be at least 12 years younger than their parent" child_12_years_younger: "A child must be at least 12 years younger than their parent"

Loading…
Cancel
Save