Skip to content

fix: skip short answer validation for empty optional answers - #3803

Open
orshih6 wants to merge 1 commit into
nextcloud:mainfrom
orshih6:contribot/issue-3802
Open

orshih6 wants to merge 1 commit into
nextcloud:mainfrom
orshih6:contribot/issue-3802

Conversation

@orshih6

@orshih6 orshih6 commented Oct 25, 2026

Copy link
Copy Markdown

When a respondent types into an optional short-text question that has a validation type (email, phone, number or regex) and then clears it, the frontend still sends [''] for that question. validateSubmission then passed the empty string to validateShortQuestion, which rejected it. The result was "Invalid input for question ..." and the form couldn't be submitted.

Empty answers are already dropped when answers are stored (storeAnswersForQuestion skips ''), so an empty short answer just means "not answered". Format validation is now skipped for it. Required questions are unaffected, because the earlier required check still rejects an empty answer with "Question ... is required.".

Tests: I added two testValidateSubmission data sets, an empty email answer on an optional question (now accepted) and on a required question (still rejected as required). The first one fails without this change. I ran the testValidateSubmission cases from SubmissionServiceTest with PHPUnit 10.5 and the nextcloud/ocp stubs, not a full server checkout, and they all pass. php-cs-fixer reports no changes.

Fixes #3802


This change was prepared with an AI coding agent (Claude) and reviewed by me before submitting. I'm happy to make any changes you'd like.

@codecov

codecov Bot commented Oct 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Chartman123

Copy link
Copy Markdown
Collaborator

@orshih6 thanks for your contribution :) Please correctly sign-off your commit so that the pipeline gets green

@Chartman123

Copy link
Copy Markdown
Collaborator

/backport to stable5.4

@backportbot backportbot Bot added the backport-request Pending backport by the backport-bot label Oct 25, 2026
@Chartman123 Chartman123 added bug Something isn't working php PHP related ticket 3. to review Waiting for reviews feature: 📝 submitting responses labels Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews backport-request Pending backport by the backport-bot bug Something isn't working feature: 📝 submitting responses php PHP related ticket

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid input for question "Email".

2 participants