(feat) O3-2972: Add disallow decimals validator #135
Merged
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.
Requirements
Summary
This PR adds a new validator that disallows entering decimal values in number fields based on the optional
disallowDecimals
property in a question definition.This feature is necessitated by how numeric concepts can specify whether they allow decimal values or not:
Presently, the number rendering type doesn't provide any validation for decimal values (nor does the Carbon NumberInput which is what it's using under-the-hood).
With this new validator, form authors can tack on a
disallowDecimals
boolean property to the question definition for anumber
field and set it totrue
if it doesn't allow decimals. Once set up, the form engine will show an error if a decimal value is entered in the field.This fix addresses an ongoing issue with the Laboratory Test Results form in the reference application. Filling the form with decimal values that lie within the reference ranges for those concepts yields an error when the form is submitted:
This error is directly related to number fields not allowing decimal values. In this case, the fields that don't allow decimal values are:
Screenshots
disallow-decimal-values.mp4
Related Issue
O3-2972
Other
Once this gets merged in, the next step is modifying the Lab Test Results form schema so that questions linked to concepts that don't allow decimal values have a
disallowDecimals
boolean property set totrue
in their question definitions.