FIO-7528: Revert FIO-4405: fixed an issue where walidation error displays with empty value even if it is not required (#4746) #5398
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.
This reverts commit 3a8d7d6.
Link to Jira Ticket
https://formio.atlassian.net/browse/FIO-7528
Description
There is a "shouldSkipValidation" function that checks for, among other things, whether or not the following conditions are satisfied:
(A) there is a custom validation
(B) the dataValue of the component is truthy
(C) the component is required
if A && !B && !C, the component will skip validating. In this case, since the value of an un-blurred select component is "", it is falsy and satisfies A && !B && !C. I'm not sure why this was introduced (I imagine to ensure that empty values that aren't required don't get validated) but we may need to reexamine our thinking behind this. In the meantime, the only workaround I can think of is to both set the field to
required
and maintain the custom validation, so both are ensured to run.Here's the line in question:
formio.js/src/components/_classes/component/Component.js
Line 3325 in 51f82ab
from this commit: formio.js: //github FIO-4405: fixed an issue where walidation error displays with empty value even if it is not required
Checklist: