-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) O3-3113: Add disallowDecimals validator #220
Conversation
@jabahum I've updated the PR description with extra context. It'd be cool if you could add a sample schema that shows how to leverage this validator, as well as a short video of it in action. |
This has been added @denniskigen |
6df2d0f
to
28c5ceb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jabahum , please address the conflicts so that we can close this
@jabahum I've tried filling in the Laboratory Test Results form and I don't see the validation kick in when entering decimal values for the |
@jabahum is the Lab Test Results form now getting validated correctly? |
@denniskigen your issue has been fixed, it was because the question was lacking min and max, so I have set a default since all the validation bases on the question having min and max |
@hadijahkyampeire the validation should be able to work regardless of whether min and max values are set. The basic premise should be that you're rendering a numeric field that doesn't allow decimals, so you add this validator to ensure that decimal values get flagged when entered into the input, min and max values notwithstanding. |
okay @denniskigen I can make it that way, I had got some information that we want to validate if the number is within the range of the min and max, and honestly it wasn't sounding correct to me as well. Thanks I will make that change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments
* add disallowDecimals attribute * fix comments * no need to translate error * do not translate error type * fix tests and merge conflicts * set default min and max * fix undefined submission * separate decimal validation from min/max validation * update translations --------- Co-authored-by: hadijahkyampeire <hadijah315@gmail.com>
Requirements
Summary
This PR implements a validator in the form engine that validates whether decimal values should be allowed in numeric obs fields. This resembles the Angular form engine's similarly named disallowDecimals validator.
The Carbon NumberInput doesn't provide any special handling for decimal values, so this validator can step in if you want to mandate that a field should not support decimals, for example. A scenario where you'd want to use this is when representing a numeric field that's backed by a concept that has
allowDecimal
set to false, such as Platelets below:Screenshots
Related Issue
Other