-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: mrf be field validation #7718
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 1085 Passed, 0 Skipped, 1m 46.57s Total duration (5m 51.94s time saved) |
c11efad
to
651ac16
Compare
9c0453a
to
5f76bcc
Compare
Pending UT. The core code is ready for review. |
dc310fd
to
892e18e
Compare
src/app/modules/submission/multirespondent-submission/multirespondent-submission.middleware.ts
Outdated
Show resolved
Hide resolved
786c586
to
b6223d5
Compare
@@ -513,8 +577,12 @@ export const validateMultirespondentSubmission = async ( | |||
).map(() => undefined) | |||
}) | |||
.andThen(() => | |||
// TODO: Step 4: Validate each field content with each field's validator rules individually. | |||
ok(undefined), | |||
validateMrfFieldResponses({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're potentially blocking submissions here and we don't have full confidence that we're making the right blocks. Would recommend us to implement this through a "shadow"[1] instead.
Lmk if you have similar concerns on the confidence of the validation implementation.
[1] We log that a validation has failed, instead of block. Once we have sufficient information and confidence, we can officially swap that to a block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, when a validation error for v3 occurs, ValidateFieldErrorV3 will be thrown which will be logged on DD and we can use that for monitoring for the next 1-2 weeks.
… feat/mrf-be-validation
Written all UT for test coverage: Field types: TC for middleware to invoke validator:
|
@@ -103,8 +109,20 @@ export const isPossibleEmailFieldSchema = ( | |||
return get(field, 'fieldType') === BasicField.Email | |||
} | |||
|
|||
export const isVerifiableMobileField = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good cleanup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Problem
BE validation is currently not performed for MRF submissions. This allows for invalid responses to be saved for MRF submissions.
For example:
Closes FRM-1688
Solution
Add validator for V3 responses and use this V3 validator in the MRF middleware which uses V3 responses.
Breaking Changes
Tests
Regression test:
Setup for next few tests:
Checkbox field validation - no duplicates with others:
Others: A
Others: A
and a customA
value in othersTable field validation:
table
field type value despiteaddMoreRows
disabled, it should reject.table
field type value, enableaddMoreRows
, it should accept.maxRowsAllowed
totable
field type value withaddMoreRows
enabled, it should reject.''
empty string, it should reject.Short text length enforced:
Children field not allowed in MRF:
children
and submit, it should reject.Decimal field range is enforced:
decimal
fieldType to beyond the valid range and submit, it should reject.Short text length is enforced:
short
fieldType to beyond the valid range and submit, it should reject.Valid country/region only:
country_region
fieldType to invalid value and submit, it should reject.NRIC must be valid:
nric
fieldType to invalid nric value and submit, it should reject.Invalid field types not allowed:
abc
and submit, it should reject.