Open stefanuebe opened 3 years ago
We had this requirement as well, instead of failing the whole process the customer wanted to show that those fields "aren't filled optimal" like e.g.
INFO
(blue), WARN
(yellow), ERROR
(red) with different color codings to show that the given value is technically valid but can still be problematic later onWARN
"Given age is greater than 100. Are you sure this person is still alive?" I created a small POC in #10683 (just the part of propagating error levels through the theme
attribute so that they can be styled as warnings or info messages; no changes to the Java API)
We find the the API proposed in the PR is problematic https://github.com/vaadin/flow/pull/10683#discussion_r625601266 but it should not be a big task to refactor it to something more versatile like suggested.
Using validators together with binders currently only allow validation / handling of errors. There are user scenarios, where entering a value should not lead to an invalid form, but at least should show a warning or allow the developer to react programmatically to such warnings. In a more general way, it could be extended to allow using all existing ErrorLevels as a ValidationResult (e. g. when an app shall differentiate between normal errors and critical ones).
Creating a ValidationResult with for instance ErrorLevel.WARNING is already possible, but the Binder / Validator API does neither support showing this warning with a respective style (looks like an error) nor does it allow to check, whether there have been warnings or not.
Therefore the requested enhancement is to extend the Validator/Binder API to allow a more generic way of using ErrorLevels, for instance by
General example use cases: