Repository navigation
feat(questions): limit the length of text answers and the range of numbers - #4032
Draft
AndyScherzinger wants to merge 6 commits into
Draft
AndyScherzinger wants to merge 6 commits into
AndyScherzinger wants to merge 6 commits into
Conversation
…mbers Form owners could only restrict text answers through a regular expression, which only short answers offer and which respondents never see. Google Forms and Microsoft Forms both let owners set a minimum and maximum character count and a number range, so answers fit where they are used later, for example in print. Short and long answers now take a minimum and a maximum length, and short answers validated as a number take a lowest and a highest number. Respondents see the rule as a hint above the field, a character counter below it, and the rule as error text when the answer breaks it. The browser stops typing at the maximum length, and the server rejects answers outside the limits. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
A short answer kept its custom validity until the debounced check ran, so submitting right after correcting an answer was silently blocked by the browser. The answer now drops its custom validity as soon as it is edited; submitting still validates every question. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Checks that owners can set a length limit, that respondents see the hints and counters and cannot submit answers outside the limits, that the server rejects them, and that a public link shows the limits. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
AndyScherzinger
force-pushed
the
feat/answer-length-number-range
branch
2 times, most recently
from
November 26, 2026 09:56
5d68878 to
040bfbb
Compare
Google Forms and Microsoft Forms offer more answer rules than a length and a number range: a number must be equal to, not equal to or not between given numbers, a text must or must not contain a word, and an answer must be a web address. Number answers now take one rule: any number, between, not between, at least, at most, equal to or not equal to. It is stored as the lowest and highest number plus numberExclude, so equal to is a range of one number and not between rejects the range. Text answers take a text they must contain and one they must not contain, ignoring case. The new URL input type accepts http and https addresses only. Respondents see each rule as a hint and the broken one as error text; the server rejects answers breaking a rule and settings that do not fit together. The Playwright spec covers the editor, the app, public links, embedded forms and the API. When the owner switches to a range rule, the editor proposes a range from the current number: at most 50 becomes 0 to 50, at least 18 becomes 18 to 100 and equal to 7 becomes 0 to 14. The new docs/AnswerRules.md explains the rules to form owners: where to set them, what respondents see, and how changing the input type or the number rule behaves, including these proposed ranges. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Google Forms and Microsoft Forms both offer strictly greater or less than and whole numbers for number answers, so owners moving over expect them. Greater than and less than reuse numberExclude: excluding the range of a single bound accepts only numbers above numberMax or below numberMin, the one-sided form of "not between". A new numberInteger setting accepts whole numbers only. The rules with one number share a single "Number" field in the editor. docs/AnswerRules.md covers the new rules, and that "Whole numbers only" stays on when the owner changes the number rule. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
At most had no test at all and at least no end-to-end one; several rules were only checked from one side. Add the missing valid answers at the bounds, the missing illegal answers per rule, the single-bound and equal settings, and set between, at least, at most and the text length limits through the editor menus. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
AndyScherzinger
force-pushed
the
feat/answer-length-number-range
branch
from
November 26, 2026 09:56
040bfbb to
f463b7d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ref #3076
Form owners can only restrict text answers through a custom regular expression today. That works for short answers only, is hard to write, and respondents never see the rule until they break it. Google Forms ("Response validation") and Microsoft Forms ("Restrictions") both let owners set character counts, number rules (between, not between, greater or less than, at least, at most, equal, not equal, whole numbers), texts an answer must or must not contain, and a URL check.
What changes
min/maxonly for the rules that accept a range.httpandhttpsaddresses only.extraSettingslengthMin,lengthMax(short, long),numberMin,numberMax,numberExclude,numberInteger,textContains,textNotContains(short) and thevalidationTypeurl, documented indocs/DataStructure.md;openapi.jsonregenerated. Equal to is stored asnumberMin=numberMax, not between and not equal to addnumberExclude: true; greater than and less than arenumberExclude: truewith onlynumberMaxornumberMin, the one-sided form of not between.docs/AnswerRules.mdfor form owners: where to set each rule, what respondents see, and how changing the input type or number rule behaves, including the range proposed when switching to between (at most 50 → 0 to 50, at least 18 → 18 to 100, equal to 7 → 0 to 14).@nextcloud/vuehas no character counter;NcTextField/NcTextAreaonly offer ahelperText, and the question fields are native inputs, so the counter and hint are built from the existing info and error note cards of the question.Includes the fix of #4033 (a corrected short answer could not be submitted right away, also on
main), which the end-to-end test needs; that commit drops out on rebase once #4033 is merged.Not covered (yet)
Screenshots
Further rules
The hint before answering and the error after submitting a breaking answer, in each view.
How to test
playwright/e2e/answer-limits.spec.tscovers setting each rule in the editor, the hints, counter and errors in the app, by public link and embedded, the server rejecting each breaking answer (sent anonymously through a public share), and the server rejecting settings that do not fit together.Checked on a live Nextcloud 35 in all three contexts, in light and dark theme; axe (WCAG 2.2 AA) reports no violations in the editor and the submit views, with hints and with errors.
🤖 AI (if applicable)