Browse Source

update error messages for hard validations

pull/820/head
Kat 3 years ago
parent
commit
dafb556a1b
  1. 2
      app/models/validations/date_validations.rb
  2. 5
      config/locales/en.yml
  3. 2
      spec/models/validations/date_validations_spec.rb

2
app/models/validations/date_validations.rb

@ -10,7 +10,7 @@ module Validations::DateValidations
end
if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 3650
record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.730_days_before_tenancy_start")
record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start")
end
end

5
config/locales/en.yml

@ -122,7 +122,7 @@ en:
mrcdate:
before_tenancy_start: "Enter a major repairs date that is before the tenancy start date"
not_first_let: "Major repairs date must not be completed if the tenancy is a first let"
730_days_before_tenancy_start: "Enter a major repairs completion date that is no more than 730 days before the tenancy start date"
ten_years_before_tenancy_start: "Enter a major repairs completion date that is no more than 10 years before the tenancy start date"
void_date:
ten_years_before_tenancy_start: "Enter a void date must no more than 10 years before the tenancy start date"
before_tenancy_start: "Enter a void date must that is before the tenancy start date"
@ -319,6 +319,9 @@ en:
title: "You told us somebody in the household is pregnant"
no_females: "You also told us there are no female tenants living at the property."
females_not_in_soft_age_range: "You also told us that any female tenants living at the property are in the following age ranges:<ul><li>11 to 16</li><li>50 to 65</li></ul>"
major_repairs_date:
title_text: "You told us the time between the start of the tenancy and the major repairs completion date is more than 730 days"
hint_text: "Are you sure the time between these dates is correct?"
devise:
two_factor_authentication:

2
spec/models/validations/date_validations_spec.rb

@ -90,7 +90,7 @@ RSpec.describe Validations::DateValidations do
record.mrcdate = Time.zone.local(2012, 1, 1)
date_validator.validate_property_major_repairs(record)
expect(record.errors["mrcdate"])
.to include(match I18n.t("validations.property.mrcdate.730_days_before_tenancy_start"))
.to include(match I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start"))
end
it "must be within 10 years of the tenancy start date" do

Loading…
Cancel
Save