Fix/issue 2757 numeric validation#2958
Open
AndreaRoss96 wants to merge 2 commits intoohs-foundation:masterfrom
Open
Fix/issue 2757 numeric validation#2958AndreaRoss96 wants to merge 2 commits intoohs-foundation:masterfrom
AndreaRoss96 wants to merge 2 commits intoohs-foundation:masterfrom
Conversation
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.
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
./gradlew spotlessApplyand./gradlew spotlessCheckto check my code follows the style guide of this project../gradlew checkand./gradlew connectedCheckto test my changes locally.