effad / ValidatorFX

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

Ability not to add createCheck if key already exists. #13

Closed jrodguitar closed 2 years ago

jrodguitar commented 3 years ago

If I run this code in a block that executes multiple times, I d like the ability to check the key before i createCheck() it.

validator.createCheck()
            .dependsOn("valName", tf.textProperty())
            .withMethod(c ->
               doSomething();
            )
            .decorates(tf)
            .immediate();

now i dont have a way to easily do such check, thus i end up adding over and over the checks.

effad commented 3 years ago

I'm not sure I understand your requirements correctly. When calling createCheck() a new Check will be created whose properties may or may not be equal to a check already added to the validator. Since we use a fluent API here, the check will be created & added as soon as createCheck() is called, while it's "attributes" (dependencies, kind of decoration, etc.) will only be set afterwards.