Skip to content
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

fix: backend validation does not prevent responses on hidden fields #736

Merged
merged 16 commits into from
Nov 30, 2020

Conversation

tshuli
Copy link
Contributor

@tshuli tshuli commented Nov 26, 2020

Problem

Closes #732

Solution

  • Add check for isVisible in validateField()
  • Also updated unit tests

Tests

  • Create a form with Yes/No field, and a Number Field hidden behind it. Attempt to submit a response programatically with the number field still hidden. Submission should fail.
  • Now unhide the Number Field. Attempt to submit a response on the number field normally. Submission should pass.
  • Create email mode form with all field types (including Yes/No) hidden behind a Yes/No field. Submit while keeping the fields hidden. Submission should pass.

@tshuli tshuli force-pushed the fix/form-logic-validation branch from af138bc to a82f694 Compare November 26, 2020 14:08
@tshuli tshuli marked this pull request as ready for review November 27, 2020 10:43
@tshuli tshuli requested a review from liangyuanruo November 27, 2020 10:43
liangyuanruo
liangyuanruo previously approved these changes Nov 30, 2020
@liangyuanruo liangyuanruo dismissed their stale review November 30, 2020 02:58

To address additional comments before merging

@tshuli tshuli force-pushed the fix/form-logic-validation branch from addf7ad to c98eab1 Compare November 30, 2020 05:52
@tshuli tshuli requested a review from liangyuanruo November 30, 2020 05:55
response.answerArray.every((arr: any) => isTableRow(arr))
) {
// Check that all arrays in answerArray have the same length
const subArrLength: number = response.answerArray[0].length
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible that response.answerArray[0] is undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing out, i've added an additional check that response.answerArray[0] must be a tableRow

Copy link
Contributor

@liangyuanruo liangyuanruo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving first, please address remaining comment before merging.

@tshuli tshuli force-pushed the fix/form-logic-validation branch from eae64ee to b455c00 Compare November 30, 2020 13:41
@tshuli tshuli merged commit 0fbfc81 into develop Nov 30, 2020
@tshuli tshuli deleted the fix/form-logic-validation branch November 30, 2020 22:52
@karrui karrui mentioned this pull request Dec 1, 2020
karrui added a commit that referenced this pull request Dec 1, 2020
@tshuli tshuli restored the fix/form-logic-validation branch December 3, 2020 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backend validation does not prevent responses on hidden fields
2 participants