You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently BindingBuilder.asRequired creates a validator that compares the component's value against its HasValue.getEmptyValue. In some cases that is not useful, as a component might have multiple empty states. Consider the RichTextEditor.isEmpty implementation for example, which not only checks whether the value is an empty string, but also whether there are only empty HTML tags.
Describe the solution you'd like
Make BindingBuilder.asRequired use HasValue.isEmpty to test whether the field has a value or not. That would allow components to have a custom HasValue.isEmpty implementation which would be respected by the validator.
At least at the moment, it looks like the respective default implementations of isEmpty do the same as the validator created in asRequired.
Describe alternatives you've considered
A hacky workaround to make this work in a component would be to customize HasValue.getEmptyValue to return the actual component value if HasValue.isEmpty returns true, so that the validator is triggered. However that might also require overriding HasValue.clear to not use HasValue.getEmptyValue and instead use some constant value.
Alternatively, users could create custom validators instead of relying on the default validator created by asRequired.
The text was updated successfully, but these errors were encountered:
A hacky workaround to make this work in a component would be to customize HasValue.getEmptyValue to return the actual component value if HasValue.isEmpty returns true, so that the validator is triggered.
Describe your motivation
Currently
BindingBuilder.asRequired
creates a validator that compares the component's value against itsHasValue.getEmptyValue
. In some cases that is not useful, as a component might have multiple empty states. Consider theRichTextEditor.isEmpty
implementation for example, which not only checks whether the value is an empty string, but also whether there are only empty HTML tags.Describe the solution you'd like
Make
BindingBuilder.asRequired
useHasValue.isEmpty
to test whether the field has a value or not. That would allow components to have a customHasValue.isEmpty
implementation which would be respected by the validator.At least at the moment, it looks like the respective default implementations of
isEmpty
do the same as the validator created inasRequired
.Describe alternatives you've considered
A hacky workaround to make this work in a component would be to customize
HasValue.getEmptyValue
to return the actual component value ifHasValue.isEmpty
returns true, so that the validator is triggered. However that might also require overridingHasValue.clear
to not useHasValue.getEmptyValue
and instead use some constant value.Alternatively, users could create custom validators instead of relying on the default validator created by
asRequired
.The text was updated successfully, but these errors were encountered: