From 3ee6f8fda6aedf2b3e6f410a2647f845473ed932 Mon Sep 17 00:00:00 2001 From: Kevin Foong <55353265+kevin9foong@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:42:02 +0800 Subject: [PATCH] feat(mrf be validation): enable mrf response validation hard block (#7963) * feat: enable mrf response validation hard block * feat: add route mapping for FieldValidationErrorV3 --- .../multirespondent-submission.middleware.ts | 5 +---- src/app/modules/submission/submission.utils.ts | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/modules/submission/multirespondent-submission/multirespondent-submission.middleware.ts b/src/app/modules/submission/multirespondent-submission/multirespondent-submission.middleware.ts index 728f5b6841..bc1f243a13 100644 --- a/src/app/modules/submission/multirespondent-submission/multirespondent-submission.middleware.ts +++ b/src/app/modules/submission/multirespondent-submission/multirespondent-submission.middleware.ts @@ -531,16 +531,13 @@ export const validateMultirespondentSubmission = async ( }) }) .andThen((previousResponses) => { - // TODO: (FRM-1688) Set to block after sure that validation logic works as expected. - validateMrfFieldResponses({ + return validateMrfFieldResponses({ formId, visibleFieldIds, formFields: form_fields, responses: req.body.responses, previousResponses, }) - - return ok(req.body.responses) }), ) }, diff --git a/src/app/modules/submission/submission.utils.ts b/src/app/modules/submission/submission.utils.ts index 24bc51ee6a..495fc5f91d 100644 --- a/src/app/modules/submission/submission.utils.ts +++ b/src/app/modules/submission/submission.utils.ts @@ -135,6 +135,7 @@ import { SubmissionSaveError, UnsupportedSettingsError, ValidateFieldError, + ValidateFieldErrorV3, VirusScanFailedError, } from './submission.errors' import { @@ -309,6 +310,7 @@ const errorMapper: MapRouteError = ( 'Submission too large to be saved. Please reduce the size of your submission and try again.', } case ValidateFieldError: + case ValidateFieldErrorV3: case DatabaseValidationError: case InvalidFileExtensionError: case AttachmentTooLargeError: