do you need javax validation constraints for a primitive boolean?

You can’t do the same as a Boolean with @NotNull annotation for a primitive boolean, because the primitive boolean has only 2 possible values, and none of them represent the lack of a value.

If you want a 3-state value, with states true, false, and missing, you must use Boolean.

Or you can use an enum with 3 values.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top