title: Hibernate validator validate empty field where is not @NotEmpty
body: <p>I have problem with Hibernate Validator 4.3.1. </p>
  
  <p>The problem is, that the validator is validating fields with are empty and don't have @NotEmpty annotations. </p>
  
  <p>When person's web form gets submitted and address, phone, fax and webpage are not set, an validation error is thrown. I think that's wrong, because there is no @NotEmpty annotation. I want skip fields with don't have @NotEmpty annotation.</p>
  
  <p>Can anyone explain where the problem is? Thank you.</p>
  
  <pre><code>public class Person{
  
      private String name;
      private String notifiedBodyCode;
      private Address address;
      private String webpage;
      private String phone;
      private String fax;
      private String email;
  
      @Column(name = "name", length = 100)
      @NotEmpty(message = "{NotEmpty.NotifiedBody.name}")
      @Length(max = 100)
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @NotEmpty
      @Column(name = "notified_body_code", length = 25)
      @Length(max = 25)
      public String getNotifiedBodyCode() {
          return notifiedBodyCode;
      }
  
      public void setNotifiedBodyCode(String notifiedBodyCode) {
          this.notifiedBodyCode = notifiedBodyCode;
      }
  
      @Valid
      @ManyToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
      public Address getAddress() {
          return address;
      }
  
      public void setAddress(Address address) {
          this.address = address;
      }
  
      @Pattern(regexp = "^(https?://)?[a-z_0-9\\-\\.]+\\.[a-z]{2,4}.*$")
      @Column(name = "web", length = 50)
      public String getWebpage() {
          return webpage;
      }
  
      public void setWebpage(String webpage) {
          this.webpage = webpage;
      }
  
      @Length(min = 9, max = 20)
      @Pattern(regexp ="[0-9\\+\\s]")
      @Column(name = "phone", length = 20)
      public String getPhone() {
          return phone;
      }
  
      public void setPhone(String phone) {
          this.phone = phone;
      }
  
      @Length(min = 9, max = 20)
      @Column(name = "fax", length = 20)
      public String getFax() {
          return fax;
      }
  
      public void setFax(String fax) {
          this.fax = fax;
      }
  
  }
  </code></pre>
  
  <p><strong>Address</strong></p>
  
  <pre><code>public class Address{
  
  
      private String city;
      private String street;
      private String zip;
      private Country country;
  
  
      @Length(max = 50)
      @Column( name = "city", length= 50)
      public String getCity() {
          return city;
      }
  
      public void setCity(String city) {
          this.city = city;
      }
  
      @Length(max = 100)
      @Column( name = "street", length= 100)
      public String getStreet() {
          return street;
      }
  
      public void setStreet(String street) {
          this.street = street;
      }
  
      @Length(min = 5, max = 6)
      @Pattern(regexp = "^[\\d\\s]$")
      @Column(name = "zip", length = 6)
      public String getZip() {
          return (zip == null ? "" : zip);
      }
  
      public void setZip(String zip) {
          this.zip = zip;
      }
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "country_id")
      public Country getCountry() {
          return country;
      }
  
      public void setCountry(Country country) {
          this.country = country;
      }
  
  }
  </code></pre>
  
  <p><strong>Country</strong></p>
  
  <pre><code>public class Country{
  
      private String countryName;
  
      @NotEmpty
      @Length(max = 45)
      @Column(name = "country_name", length = 45)
      public String getCountryName() {
          return countryName;
      }
  
      public void setCountryName(String countryName) {
          this.countryName = countryName;
      }
  
      @Override
      public String toString() {
          return "Country [id=" + id + ", countryName=" + countryName + "]";
      }
  
  }
  </code></pre>
  
  <p><strong>EDIT - Problem solved.</strong></p>
  
  <p>Problem was in <code>"^"</code> expression. I have to use <code>"[^|]"</code> instead.</p>