Repository navigation
fix: skip short answer validation for empty optional answers - #3803
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@orshih6 thanks for your contribution :) Please correctly sign-off your commit so that the pipeline gets green |
|
/backport to stable5.4 |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
|
@orshih6 could you please fix the DCO workflow by signing off your commit? I'd like to merge this. |
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.validateSubmissionthen passed the empty string tovalidateShortQuestion, 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 (
storeAnswersForQuestionskips''), 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
testValidateSubmissiondata 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 thetestValidateSubmissioncases fromSubmissionServiceTestwith PHPUnit 10.5 and thenextcloud/ocpstubs, 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.