-
Notifications
You must be signed in to change notification settings - Fork 167
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
Binder.validate() fails with "bean level validators have been configured but no bean is currently set" when in buffered mode #18120
Comments
…el validations are defined. Fixes #18120
I agree that the javadoc/contract of the method is correct, but the implementation throws unexpectedly and this isn't correct. This inconsistency causes apparently problems like described in this issue #13393. |
Investigated this a bit further. One thing to consider is that regardless of the discrepancy between javadoc and real functionality, this logic has been in place about six years and care should be taken if it will be changed - especially if it is done via silently ignoring bean-level validators. On the other hand, writing the bean will eventually run the bean-level validators so changing the functionality to match javadoc is probably not too dangerous. That said, one option might be to:
Benefit of this would also be earlier release (or backporting) since current functionality would not be changed. |
Unfortunately there already is an overloaded Also, having the overloaded function would basically bring back the old behavior of throwing an exception if bean-level validators are defined; I wonder what value this use-case brings, except for the compatibility reason of course. |
You are right on both counts. But I'm afraid that if the |
True, it's always good to be conscious on the backwards compatibility. I'd say that this ticket has been present in Vaadin for 6 years, so waiting a bit wouldn't hurt; and personally I would prefer to have simpler&cleaner API. So, personally I would vote to go for the "breaking change" option, and release this as part of next major version. |
As I said, the contract of The javadoc says for I cannot come up with a good example, but there might be existing use cases in projects when form validation relies on Older versions need an update of javadoc to reflect the implementation (tell that this methods might throw). It means a behaviour change. Finally, I propose to follow what Martin said and apply this patch to the next major version (I have a list of TODOs and going to add this there). |
Description of the bug
When using binder in buffered mode with bean-level validators and calling
validate()
, the function fails with:That contradicts the javadoc of
Binder.validate()
, which states thatThe use-case for having
validate()
not failing was described at #15701 ; however that ticket is marked as enhancement while I believe this to be a buggy behavior.Expected behavior
Binder.validate()
should not fail when in buffered mode and bean-level validators are set. Instead, the bean-level validators should be skipped silently.Minimal reproducible example
Versions
The text was updated successfully, but these errors were encountered: