Skip to content

Commit

Permalink
fix: ensure number of non-editable fields did not change between subm…
Browse files Browse the repository at this point in the history
…ission
  • Loading branch information
KenLSM committed Aug 22, 2024
1 parent e7418d5 commit 1b3f291
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,20 @@ export const validateMultirespondentSubmission = async (
const previousResponses =
previousSubmissionDecryptedContent.responses as ParsedClearFormFieldResponsesV3

const previousNonEditableFieldIdsWithResponses = Object.keys(
previousResponses,
).filter((fieldId) => !editableFieldIds.includes(fieldId))
if (
previousNonEditableFieldIdsWithResponses.length !==
nonEditableFieldIdsWithResponses.length
) {
return err(
new ProcessingError(
'Number of non-editable fields in previous submission does not match number of non-editable fields in current submission',
),
)
}

return Result.combine(
nonEditableFieldIdsWithResponses.map((fieldId) => {
const incomingResField = req.body.responses[fieldId]
Expand Down

0 comments on commit 1b3f291

Please sign in to comment.