Hi,

I was just wondering if any thought has been put into providing a standard 
approach to validating input? Something like ValidatorFX for example [1]? There 
have been attempts at solving this in ControlsFX but that one was too heavily 
bound to the actual controls while ValidatorFX works on anything that is 
observable. I have been using it now for several years in our CRM desktop 
application and I feel like it is striking a perfect balance between being 
flexible and easy to use.

Small / incomplete example:

        TextField userTextField = new TextField();

        Validator validator = new Validator();
        validator.createCheck()
          .dependsOn("username", userTextField.textProperty())
          .withMethod(c -> {
                    String userName = c.get("username");
                    if (!userName.toLowerCase().equals(userName)) {
                         c.error("Please use only lowercase letters.");
                        }
                })
          .decorates(userTextField)
          .immediate();

I know that one can easily say “just use the library” but I think that not 
everybody will find it and it also is nice to have a standard way of doing 
things.

Dirk

[1] https://github.com/effad/ValidatorFX

Reply via email to