Skip to content
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

Validators do not handle null input #67

Open
nibsky opened this issue May 2, 2023 · 0 comments
Open

Validators do not handle null input #67

nibsky opened this issue May 2, 2023 · 0 comments

Comments

@nibsky
Copy link

nibsky commented May 2, 2023

For example in IntegerRangeValidator:

public class IntegerRangeValidator extends CustomValidator<Integer> {

    private IntegerRangeValidator(int min, int max, String errorMessage) {
        super(input -> input >= min && input <= max, errorMessage);
    }
 ....

Could be:

public class IntegerRangeValidator extends CustomValidator<Integer> {

    private IntegerRangeValidator(int min, int max, String errorMessage) {
        super(input -> null != input && input >= min && input <= max, errorMessage);
    }
 ....

Some background on my usage:
I had set the IntegerRangeValidator into a SingleSelectionField (Selection bound to an IntegerProperty).
Due to some design constraint, I needed to change the SingleSelectionField content using SingleSelectionField.items(List).. This part nullifies the bound IntegerProperty until I use SingleSelectionField.select(0).
This causes an unhandled NullPointerException.

Kindly correct me if I overlooked a better approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant