Skip to content

Fix/issue 2757 numeric validation#2958

Open
AndreaRoss96 wants to merge 2 commits intoohs-foundation:masterfrom
AndreaRoss96:fix/issue-2757-numeric-validation
Open

Fix/issue 2757 numeric validation#2958
AndreaRoss96 wants to merge 2 commits intoohs-foundation:masterfrom
AndreaRoss96:fix/issue-2757-numeric-validation

Conversation

@AndreaRoss96
Copy link

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #2757

Description
Updated EditTextIntegerViewHolderFactory and EditTextDecimalViewHolderFactory to dynamically pull minValue and maxValue constraints from the Questionnaire item extensions when displaying validation error messages for draft answers.
Previously, the error message was hardcoded to display the technical limits of the data type (Int.MIN_VALUE and Int.MAX_VALUE), which was confusing for end-users. The logic now checks for the FHIR minValue and maxValue extensions, falling back to the data type limits only if no specific constraints are defined in the Questionnaire.
Alternative(s) considered
I considered moving this logic entirely into a shared utility function within QuestionnaireItemExtensions.kt, but since the uiValidationMessage block in the Compose-based ViewHolders specifically handles the draftAnswer state (where a full validation result isn't yet available), keeping the logic within the factory ensures the immediate feedback matches the defined constraints.

Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?

Type
Bug fix

Screenshots (if applicable)
N/A

Checklist

  • I have read and acknowledged the Code of conduct.
  • I have read the Contributing page.
  • I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Number question validation message does not consider min max value given in the question

1 participant