JAX-RS separates quite nicely the deserialization from the validation, i.e. JSON-B (or Jackson) has by design no mechanism to enforce values to be non-null
, etc. Instead, you can use BeanValidation for that:
- Add a dependency to
javax.validation:validation-api
inprovided
scope. - Add the
javax.validation.constraints.NotNull
annotation to your field.
For more details, go here.