Browse Source

feat: update validations

pull/1570/head
natdeanlewissoftwire 3 years ago
parent
commit
222d512c60
  1. 1
      app/models/validations/financial_validations.rb
  2. 3
      app/models/validations/shared_validations.rb
  3. 3
      config/locales/en.yml
  4. 2
      spec/models/validations/shared_validations_spec.rb

1
app/models/validations/financial_validations.rb

@ -6,6 +6,7 @@ module Validations::FinancialValidations
def validate_outstanding_rent_amount(record)
if !record.has_housing_benefit_rent_shortfall? && record.tshortfall.present?
record.errors.add :tshortfall, :no_outstanding_charges, message: I18n.t("validations.financial.tshortfall.outstanding_amount_not_required")
record.errors.add :hbrentshortfall, :no_outstanding_charges, message: I18n.t("validations.financial.hbrentshortfall.outstanding_amount_not_required")
end
end

3
app/models/validations/shared_validations.rb

@ -47,8 +47,7 @@ module Validations::SharedValidations
postcode = record.ppostcode_full
if record.previous_postcode_known? && (postcode.blank? || !postcode.match(POSTCODE_REGEXP))
error_message = I18n.t("validations.postcode")
record.errors.add :ppostcode_full, message: error_message
record.errors.add :ppcodenk, message: error_message
record.errors.add :ppostcode_full, :wrong_format, message: error_message
end
end

3
config/locales/en.yml

@ -244,6 +244,7 @@ en:
more_than_rent: "Enter a value less less than the basic rent amount"
must_be_positive: "Enter a value over £0.01 as you told us there is an outstanding amount"
hbrentshortfall:
outstanding_amount_not_required: "You must have outstanding rent or charges as you have answered the outstanding amount question"
outstanding_no_benefits: "Answer cannot be ‘yes’ to outstanding amount for basic rent or charges if tenant does not receive housing benefit or Universal Credit or you‘re not sure"
benefits:
part_or_full_time: "Answer cannot be ‘all’ for income from Universal Credit, state pensions or benefits if the tenant or their partner works part-time or full-time"
@ -629,6 +630,8 @@ en:
offered: "Times previously offered since becoming available"
warnings:
bulk_upload_log_creation_logs: "There is 1 log in this bulk upload with 1 error that still 1 need to be fixed after upload."
bulk_upload_log_creation_errors: "There is 1 log in this bulk upload with 1 error that still 1 need to be fixed after upload."
location:
deactivate:
existing_logs: "It will not be possible to add logs with this location if their tenancy start date is on or after the date you enter. Any existing logs may be affected."

2
spec/models/validations/shared_validations_spec.rb

@ -128,7 +128,6 @@ RSpec.describe Validations::SharedValidations do
shared_validator.validate_previous_accommodation_postcode(record)
expect(record.errors).not_to be_empty
expect(record.errors["ppostcode_full"].first).to eq(I18n.t("validations.postcode"))
expect(record.errors["ppcodenk"].first).to eq(I18n.t("validations.postcode"))
end
it "does not add an error if the record ppostcode_full is valid (uppercase space)" do
@ -151,7 +150,6 @@ RSpec.describe Validations::SharedValidations do
shared_validator.validate_previous_accommodation_postcode(record)
expect(record.errors).not_to be_empty
expect(record.errors["ppostcode_full"].first).to eq(I18n.t("validations.postcode"))
expect(record.errors["ppcodenk"].first).to eq(I18n.t("validations.postcode"))
end
end
end

Loading…
Cancel
Save