Open ysm-coder opened 4 years ago
This is nicely solved in the validation support inside of the form builder. Please see Validation section of the guide, on this page: https://github.com/edvin/tornadofx-guide/blob/master/part1/11.%20Editing%20Models%20and%20Validation.md
I couldnt find it in the guide, but bassicaly if I have some constraints (like String should only contain lowercase letters) I would check them in the setters and if something is wrong I can throw an
Exception
, display anAlert
,return
from the setter without setting anything or whatever. But in tornadofx I dont havevar
+setters but instead I haveval
properties likeSimpleStringProperty
. So what should I do? One idea is to somehow check this in.onChange{}
but the problems I see with it is that this happens after the change (what if someone else also listens to the change and does something before I can check the constraint, also how do I get my old value back?). What is the intended way to do this?