Am 04.03.24 um 10:01 schrieb Michael Strauß:
I would not be in favor of adding any particular data validation
framework to JavaFX. Data validation comes in all kinds of different
shapes and sizes, which makes it a good fit for (opinionated)
third-party libraries.

I agree with that while at the same time trying to provide different options (opinions) with ValidatorFX.


However, I fully agree with John that JavaFX
should provide more APIs that can only realistically be implemented in
FX. I've proposed a "significant interaction" API, which is crucial
for many data validation scenarios:
https://mail.openjdk.org/pipermail/openjfx-dev/2023-March/039327.html

Shame on me, I totally missed that thread. It contains a lot of insight.

Interestingly, ValidatorFX (since 0.5.0) supports these different modes at the moment:

* immediate (which you call "Eager" in the thread above)

* explicit (which you call "Submit")

* immediate-after-submit: This leaves the user undisturbed until they first press the "submit" button. After that, the form changes into immediate mode, only then highlighting everything that has to be corrected.

* explicit with immediate clearing: Validation happens on submit, but as soon as the user changes any of the validated properties, validation is reset so that the user has some "breathing space" when correcting their input

An implementation of your "second" mode, which will redo validation on "significant user input" is missing at the moment. But I think this should be possible to do with sth. like a .checkedOn(ObservableValue<Boolean> userModifiedProperty) method. That will still leave the burden of defining the userModifiedProperty to the application but that is probably for the best: For a "required" check, getting and losing the focus is not a significant user input, while a field that requires either no input at all or a valid SSN may use the lost focus for that.

To that end, I've just created https://github.com/effad/ValidatorFX/issues/37.

--Robert

Reply via email to