effad / ValidatorFX

A form validation library for JavaFX
BSD 3-Clause "New" or "Revised" License
221 stars 19 forks source link

Add a clear() method to Validator class. #32

Closed gldiazcardenas closed 9 months ago

gldiazcardenas commented 1 year ago

It could be useful to clear up all decorations and start over.

effad commented 1 year ago

Yes, I can see that as useful, if checks are not .immediate(). Implementation would require a clear method in Validator, which in turn calls a clear method of all Checks which would then remove all decorations. It must also set a new, empty ValidationResult. One question remains: What do we do, if checks are immediate? Should a recheck happen for them? Or would it be better to not "touch" them until the user does? In that way a hybrid mode could be implemented where checks are immediate but only after the user changed the value once ...

gldiazcardenas commented 1 year ago

actually the immediate mode is a topic for further discussion.. nobody likes a red form right after opening it.. another use case I could think about clear() method is when you let the user copy values from external sources, for example, loading a file, or copy from another object; but the submit button might have already been clicked, so you want to clear all validations.

effad commented 9 months ago

A clear() method has been added to both Check and Validator class. This will be part of the upcoming 0.5.0 release.