title: Bean Validation using JAX-RS and DTO parameters
body: <p>I'm trying to use Bean Validations on my JAX-RS services. But I can't make it work with validations using a JSON object instead of simple parameters. </p>
  
  <p>I have this REST interface:</p>
  
  <pre><code>@Path("persons")
  @Produces(MediaType.APPLICATION_JSON)
  public class PersonRestService {
  
      @EJB
      private GreeterEJBLocal greeterEJB;
  
      @POST
      @Path("greet")
      @Consumes(MediaType.APPLICATION_JSON)
      public SayHelloRestResponse sayHello(SayHelloRestRequest sayHelloRestRequest) {
          SayHelloRestResponse sayHelloRestResponse = new SayHelloRestResponse();
          Person person = new Person();
          person.setName(sayHelloRestRequest.person.name);
          person.setEmail(sayHelloRestRequest.person.email);
  
          SayHelloRequest sayHelloRequest = new SayHelloRequest();
          sayHelloRequest.setPerson(person);
  
          SayHelloResponse sayHelloResponse = greeterEJB.sayHello(sayHelloRestRequest.person.name, sayHelloRestRequest.person.email);
  
          sayHelloRestResponse.setMessage(sayHelloResponse.getMessage());
  
          return sayHelloRestResponse;
      }
  }
  </code></pre>
  
  <p>And this is my DTO with Bean Validation annotations:</p>
  
  <pre><code>public class SayHelloRestRequest implements Serializable {
  
      // Default serial version UID
      private static final long serialVersionUID = 1L;
  
      public Person person;
  
      public static class Person {
          @Size(min = 2, max = 5, message = "{person.name.size}")
          public String name;
          @Email(message = "{person.email.email}")
          public String email;
      }
  
  }
  </code></pre>
  
  <p>When I'm testing the service never fail for the validation. I don't know I'm doing wrong. There is a screenshot were I'm testing the service</p>
  
  <p><a href="https://i.stack.imgur.com/ccAZB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ccAZB.png" alt="enter image description here"></a></p>