Skip to content

Commit ba74db8

Browse files
committed
Clarify MMR historical dose sequence validation message
Make the validation error for invalid MMR historical dose sequence values more consistent when uploading vaccination records. Before this change, invalid values such as `3` and `2B` could show different error messages. This change updates the wording so they now both show the same message explaining that the dose sequence cannot be greater than 2. This follows on from commit 9035a26. Jira-Issue: MAV-2312
1 parent edc4163 commit ba74db8

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

app/models/immunisation_import_row.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -851,13 +851,15 @@ def validate_dose_sequence
851851
two_words_connector: " or "
852852
)
853853

854+
dose_sequence_error_message =
855+
"The dose sequence number cannot be greater than " \
856+
"#{maximum_dose_sequence}. Enter a dose sequence number, " \
857+
"for example, #{dose_sequence_examples}."
858+
854859
if dose_sequence.present? ||
855860
parsed_vaccination_description_string&.dig(:dose_sequence).present?
856861
if dose_sequence_value.nil?
857-
errors.add(
858-
field.header,
859-
"Enter a dose sequence number, for example, #{dose_sequence_examples}."
860-
)
862+
errors.add(field.header, dose_sequence_error_message)
861863
elsif maximum_dose_sequence
862864
if dose_sequence_value < 1
863865
errors.add(field.header, "must be greater than 0")
@@ -879,10 +881,7 @@ def validate_dose_sequence
879881
end
880882
)
881883
else
882-
errors.add(
883-
field.header,
884-
"Enter a dose sequence number, for example, #{dose_sequence_examples}."
885-
)
884+
errors.add(field.header, dose_sequence_error_message)
886885
end
887886
end
888887
end

spec/models/immunisation_import_row_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@
582582
it "has the correct error message" do
583583
immunisation_import_row.valid?
584584
expect(immunisation_import_row.errors["DOSE_SEQUENCE"]).to include(
585-
"Enter a dose sequence number, for example, 1 or 2."
585+
"The dose sequence number cannot be greater than 2. Enter a dose sequence number, for example, 1 or 2."
586586
)
587587
end
588588
end

0 commit comments

Comments
 (0)