Browse Source

refactor: standardise check for presence of needs type

pull/1524/head
Sam Seed 2 years ago
parent
commit
5d31277bee
  1. 8
      app/services/bulk_upload/lettings/year2023/row_parser.rb

8
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -292,6 +292,7 @@ class BulkUpload::Lettings::Year2023::RowParser
validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 7 must be a number or the letter R" }, allow_blank: true, on: :after_log validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 7 must be a number or the letter R" }, allow_blank: true, on: :after_log
validates :field_76, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 8 must be a number or the letter R" }, allow_blank: true, on: :after_log validates :field_76, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 8 must be a number or the letter R" }, allow_blank: true, on: :after_log
validates :field_4, presence: { message: I18n.t("validations.not_answered", question: "needs type") }, on: :after_log
validates :field_6, presence: { message: I18n.t("validations.not_answered", question: "property renewal") }, on: :after_log validates :field_6, presence: { message: I18n.t("validations.not_answered", question: "property renewal") }, on: :after_log
validates :field_7, presence: { message: I18n.t("validations.not_answered", question: "tenancy start date (day)") }, on: :after_log validates :field_7, presence: { message: I18n.t("validations.not_answered", question: "tenancy start date (day)") }, on: :after_log
validates :field_8, presence: { message: I18n.t("validations.not_answered", question: "tenancy start date (month)") }, on: :after_log validates :field_8, presence: { message: I18n.t("validations.not_answered", question: "tenancy start date (month)") }, on: :after_log
@ -299,7 +300,6 @@ class BulkUpload::Lettings::Year2023::RowParser
validates :field_9, format: { with: /\A\d{2}\z/, message: I18n.t("validations.setup.startdate.year_not_two_digits") }, on: :after_log validates :field_9, format: { with: /\A\d{2}\z/, message: I18n.t("validations.setup.startdate.year_not_two_digits") }, on: :after_log
validate :validate_needs_type_present, on: :after_log
validate :validate_data_types, on: :after_log validate :validate_data_types, on: :after_log
validate :validate_nulls, on: :after_log validate :validate_nulls, on: :after_log
validate :validate_relevant_collection_window, on: :after_log validate :validate_relevant_collection_window, on: :after_log
@ -439,12 +439,6 @@ private
end end
end end
def validate_needs_type_present
if field_4.blank?
errors.add(:field_4, I18n.t("validations.not_answered", question: "needs type"))
end
end
def start_date def start_date
return if field_7.blank? || field_8.blank? || field_9.blank? return if field_7.blank? || field_8.blank? || field_9.blank?

Loading…
Cancel
Save