Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Last active January 22, 2016 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/4c68d9b306cfdfbf6d06 to your computer and use it in GitHub Desktop.
Save abhirockzz/4c68d9b306cfdfbf6d06 to your computer and use it in GitHub Desktop.
Bean Validation in action in JAX-RS
@Path("users")
public class UsersResource {
@HeaderParam("token")
@Valid
private Token token;
@POST
@Produces("application/json")
@Consumes("application/json")
public void save(@Valid User user){
System.out.println("saved :: " + user);
}
@GET
@Path("{name}")
@Produces("application/json")
public @Valid User get(@PathParam("name") String name){
return new User(name, name+"@test.com");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment