Browse Source

feat: validate uprn not in scientific notation

CLDC-2349-scientific-notation-uprn-error
natdeanlewissoftwire 2 years ago
parent
commit
91a61bb1b9
  1. 8
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  2. 7
      app/services/bulk_upload/sales/year2023/row_parser.rb

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

@ -384,6 +384,7 @@ class BulkUpload::Lettings::Year2023::RowParser
validate :validate_nulls, on: :after_log
validate :validate_uprn_exists_if_any_key_address_fields_are_blank, on: :after_log
validate :validate_uprn_not_in_scientific_notation, on: :after_log
validate :validate_incomplete_soft_validations, on: :after_log
@ -509,6 +510,13 @@ private
end
end
def validate_uprn_not_in_scientific_notation
if field_18.&include?("E")
errors.add(:field_19, I18n.t("validations.invalid_option", question: "UPRN"))
end
end
def validate_incomplete_soft_validations
routed_to_soft_validation_questions = log.form.questions.filter { |q| q.type == "interruption_screen" && q.page.routed_to?(log, nil) }.compact
routed_to_soft_validation_questions.each do |question|

7
app/services/bulk_upload/sales/year2023/row_parser.rb

@ -410,6 +410,7 @@ class BulkUpload::Sales::Year2023::RowParser
validate :validate_incomplete_soft_validations, on: :after_log
validate :validate_uprn_exists_if_any_key_address_fields_are_blank, on: :after_log
validate :validate_uprn_not_in_scientific_notation, on: :after_log
validate :validate_address_fields, on: :after_log
validate :validate_if_log_already_exists, on: :after_log, if: -> { FeatureToggle.bulk_upload_duplicate_log_check_enabled? }
@ -512,6 +513,12 @@ private
end
end
def validate_uprn_not_in_scientific_notation
if field_19&.include?("E")
errors.add(:field_19, I18n.t("validations.invalid_option", question: "UPRN"))
end
end
def validate_address_fields
if field_19.blank? || log.errors.attribute_names.include?(:uprn)
if field_20.blank?

Loading…
Cancel
Save