title: javax.validation is not working in spring boot RESTful app?
body: <p>i trying to validate my Model class, which is named user.java, i trying to validate the column to prevent it not empty and the email is should be email format, and i use @RepositoryRestController to create my CRUD api, but how do i do this properly?</p>
  
  <p>here is my user.java :</p>
  
  <pre><code>package com.mechadevapi.mechadev.Models;
  
  import java.util.Date;
  
  import javax.validation.constraints.Email;
  import javax.validation.constraints.NotBlank;
  
  import org.springframework.data.annotation.Id;
  
  public class User {
  
      @Id
      public String Id;
  
      @NotBlank(message = "is empty")
      public String username;
      @NotBlank(message = "is empty")
      @Email(message = "should be email")
      public String email;
      @NotBlank(message = "is empty")
      public String firstname;
      public String lastname;
      @NotBlank(message = "is empty")
      public String password;
      @NotBlank(message = "is empty")
      public String level;
      @NotBlank(message = "is empty")
      public Boolean activation;
      public Date entry_time;
      public Date last_login;
  
      public String getId() {
          return Id;
      }
  
      public void setId(String id) {
          Id = id;
      }
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getFirstname() {
          return firstname;
      }
  
      public void setFirstname(String firstname) {
          this.firstname = firstname;
      }
  
      public String getLastname() {
          return lastname;
      }
  
      public void setLastname(String lastname) {
          this.lastname = lastname;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getLevel() {
          return level;
      }
  
      public void setLevel(String level) {
          this.level = level;
      }
  
      public Boolean getActivation() {
          return activation;
      }
  
      public void setActivation(Boolean activation) {
          this.activation = activation;
      }
  
      public Date getEntry_time() {
          return entry_time;
      }
  
      public void setEntry_time() {
          Date entry_time = new Date();
  
          this.entry_time = entry_time;
      }
  
      public Date getLast_login() {
          return last_login;
      }
  
      public void setLast_login() {
          Date last_login = new Date();
  
          this.last_login = last_login;
      }
  
  
  
  }
  </code></pre>
  
  <p>and here is my repository, UserRepository.java :</p>
  
  <pre><code>package com.mechadevapi.mechadev.Repository;
  
  import javax.validation.Valid;
  
  import com.mechadevapi.mechadev.Models.*;
  
  import org.springframework.data.mongodb.repository.MongoRepository;
  import org.springframework.data.rest.core.annotation.RepositoryRestResource;
  
  @RepositoryRestResource(collectionResourceRel = "user", path = "user")
  @Valid
  public interface UserRepository extends MongoRepository&lt;User, String&gt; {
  
  }
  </code></pre>
  
  <p>when i trying to post the data using postman, which is looked like this :</p>
  
  <pre><code>{
      "username" : "admin",
      "email" : 123,
      "firstname" : "ad",
      "lastname" : "min",
      "password" : "123456",
      "level" : "administrator",
      "activation" : true
  }
  </code></pre>
  
  <p>the data still saved, it's like the javax.validation anotation is not working, how do i validate this properly?</p>