feat(DCP-2527): add min/max validation for free_text and free_text_with_unit instructions#354
Merged
script-this merged 1 commit intomainfrom Mar 16, 2026
Merged
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
a02a78f to
970b5e8
Compare
…th_unit instructions Add ValidationRule struct and Validation field to support optional min/max bounds on free_text (instruction-level) and free_text_with_unit (per unit_option) instruction types. Validation logic is deferred to the backend; the CLI passes the field through and surfaces API errors.
970b5e8 to
77b7886
Compare
dessskris
approved these changes
Mar 16, 2026
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.
Summary
Adds optional
validationfield support forfree_textandfree_text_with_unitinstruction types, enabling min/max bounds on user input. Validation logic is deferred to the backend — the CLI passes the field through and surfaces API errors directly.Validation Schema
{ "type": "number" | "string", "min": number | null, "max": number | null }free_text:validationis a top-level field on the instructionfree_text_with_unit:validationis per-unit_option(each unit can have different bounds)typeis required;min/maxare nullable (null= unbounded in that direction)Usage Examples
Collection JSON with
free_textstring validation (character count bounds):{ "order": 1, "type": "free_text", "description": "How was your experience completing this task?", "validation": { "type": "string", "min": 10, "max": 500 } }Collection JSON with
free_text_with_unitper-unit number validation:{ "order": 3, "type": "free_text_with_unit", "description": "What is your current weight?", "unit_options": [ { "label": "KG", "value": "kg", "validation": { "type": "number", "min": 20, "max": 300 } }, { "label": "Pounds", "value": "lbs", "validation": { "type": "number", "min": 44, "max": 660 } } ], "default_unit": "kg", "unit_position": "suffix" }Implementation
ValidationRulestruct tomodel/collection.goandclient/payloads.goValidationfield toInstruction,UnitOption,PageInstruction, andCollectionPageItemstructsMin/Maxuse*float64withoutomitempty— backend requires explicitnull(not field absence) for unbounded valuesTesting
Unit tests:
free_textinstructionsfree_text_with_unitwith per-unit-option validationtypespecified (no min/max)nullvalidation handled correctlyManually verified against dev:
free_textwith string validation (min/max char count) — created successfullyfree_text_with_unitwith per-unit number validation — created successfullynull) — created successfully