What options are there to do output validation of Jersey resources?

57 views Asked by At

What are my options to do output validation of entities in Jersey? Simple use case would be to validate that a returned User instance doesn't have a certain field set to non-null.

1

There are 1 answers

0
Filip On

Not sure of the context, it this at runtime, or during unit tests?

Bean Validation is one very popular validation framework.

You can readily use it to validate your input (see @NotNull, @Valid and other bean validation annotations with Jersey) ref : https://jersey.java.net/documentation/latest/bean-validation.html

If you want to validate your output, you can use the bean validation framework also, but you will need to use it manually and handle errors.

just check out one of many tutorials on bean validation : http://java.dzone.com/articles/bean-validation-made-simple