Skip to content

Support for questionnaire validation and field requirements #1925

@mpgxvii

Description

@mpgxvii

Description
The current questionnaire page needs to be updated to support advanced field properties found in our REDCap-based JSON format. Specifically, we need to implement logic for field requirement toggles, numeric input formatting, and range validation (min/max).

Proposed Changes

1. Support for Required Fields
Implement logic to respect the required_field attribute.

  • Attribute: "required_field": "y" (Required) or "" (Optional).
  • Action: If set to "y", the Next button should not be enabled unless filled.

2. Numeric Text Formatting (#1391)
Enable specific input types for text fields based on validation metadata.

  • Attribute: "text_validation_type_or_show_slider_number": "number"
  • Action: When this is set to "number", the input field should restrict entry to numeric values and potentially trigger the numeric keypad on mobile devices.

3. Range Validation (Min/Max)
Add logic to validate numeric inputs against defined boundaries.

  • Attributes: text_validation_min and text_validation_max
  • Action: Only allow numbers within the range, throw a validation error if the input falls outside the range (e.g., “Value must be between [min] and [max]”).

Technical Context
The updates should target the processing of the following JSON structure:

JSON

 {
    "field_name": "meduse_2b_1",
    "field_type": "text",
    "required_field": "y",
    "text_validation_type_or_show_slider_number": "number",
    "text_validation_min": "0",
    "text_validation_max": "500"
 }

Acceptance Criteria

  • Fields with required_field: "y" prevent form progression if null.
  • Fields with text_validation_type...: "number" only accept numeric input.
  • Error messages appear if a value is less than text_validation_min.
  • Error messages appear if a value is greater than text_validation_max.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions