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
OnDemand Validation. #102
Comments
That is possible with a workaround: if you attach a listener to the regarding elements and the validator is being applied just before the validation check (on button press) and removed as soon as something changes in the elements. |
Sorry, but I don't quite understand the issue |
That is true. It makes no sense to force the update, but in some cases it is useful to bind it to a certain element instead of any input. And if you add the binding to a certain element, it keeps on checking for any changes instead of the one event you want to look after. If I can give you an example: I want to validate the username only when the user is trying to go to the next stepper. I tried that by using the BooleanBinding to bind it to the onNextProperty of the referenced element. But as soon as I leave the loginField, it validates it. |
@Juke1999 Ah yes, now I get it, thanks for the example I wonder how I could improve it though... I mean, yes I could add a boolean flag to disable this behavior if needed, and you would be able to update the validator manually since they expose an update() method but... is this the right way to do it? |
This is one way to do it, yes. But the "to evaluate" flag is perfectly fine, as there have to be different options on how to enable such validation features. |
Thank you very much 👍🏻 |
Alright. |
@Juke1999 are you still interested in this? |
Sure, I can take a look. |
Thanks! It's very experimental. I kind of like the base idea of the "Constraint" objects, since it also allows to add many other details to the validation (such as the severity for example). I was kind of inspired by this awesome library YAVI, but it's super simplified. Edit: Oh, I also added some experimental utils, don't know if they will remain the same but they seem to be quite useful |
Alright. |
Hello @Juke1999! Like I said just minor changes. The constraints are now kept in an observable list rather than a map, I think there's no need to associate constraints to a "name", also it's observable so that when it changes (add/remove constraints) the validator state is updated automatically. Edit: Oh I forgot to change one thing in the project. The valid property of the validator must be set to true initially (change the constructor) otherwise controls (such the stepper) querying an empty validator won't proceed since the return value is false |
I'm home tomorrow and will have a look at the project. Will keep you updated! |
Yep no hurry, thanks! I'm currently remaking the demo |
Hey @palexdev, |
Thanks @Juke1999 👍🏻 |
The new Validation API is not available on the staging branch |
Alright, it looks good and handles validations fine. |
The new Validation API is now available in the latest release, closing this issue |
Is there a way to force on-demand validation? So say we have several fields which by default are marked as valid and a button that should trigger the validation and the state change ?
The text was updated successfully, but these errors were encountered: