title: Spring - Can't get same validation error structure on 2 fields
body: <p>-- First of all excuse me if my english isn't perfect ;) --</p>
  <p>I'm trying to use Custom Validator with Spring to get this structure :</p>
  <pre><code>{
      &quot;violations&quot;: [
          {
              &quot;fieldName&quot;: &quot;name&quot;,
              &quot;className&quot;: &quot;User&quot;,
              &quot;message&quot;: &quot;already exists&quot;
          }
      ],
      &quot;type&quot;: &quot;https://zalando.github.io/problem/constraint-violation&quot;,
      &quot;status&quot;: 400,
      &quot;title&quot;: &quot;API Constraint Violation&quot;
  }
  </code></pre>
  <p>So I copied some class to get the new structure :</p>
  <pre><code>@API(status = STABLE)
  @Immutable
  public class ApiViolation {
  
      private final String fieldName;
      private final String className;
      private final String message;
  
      public ApiViolation(String fieldName, String className, String message) {
          this.fieldName = fieldName;
          this.className = className;
          this.message = message;
      }
  
      public String getFieldName() {
          return fieldName;
      }
  
      public String getClassName() {
          return className;
      }
  
      public String getMessage() {
          return message;
      }
  }
  </code></pre>
  <p>And my User class :</p>
  <pre><code>@Entity
  @Table(name = &quot;user&quot;)
  @JsonFilter(&quot;JsonFieldSecurityFilter&quot;)
  @Audited
  @Indexed
  @NoArgsConstructor
  @Getter
  @Setter
  @ToString
  @SearchFields({&quot;_global&quot;})
  @UniqueUserNameConstraint
  public class User extends Instanciable implements Serializable {
  
      @Serial
      private static final long serialVersionUID = 1L;
  
      @Fields({
              @Field,
              @Field(name = &quot;_global&quot;)
      })
      @NotEmpty
      @Size(max = 256)
      private String name;
  
      @NotNull
      @ManyToOne(fetch = FetchType.EAGER)
      private Club club;
  </code></pre>
  <p>The fact is :
  1/ names can't be the same in the same club but can be the same in differents.</p>
  <p>So when I try to get an error on the club field I get a good error :</p>
  <pre><code>Field error in object 'User' on field 'club': 
  rejected value [null]; 
  codes [NotNull.User.club,NotNull.club,NotNull.com.club.api.domain.Club,NotNull]; arguments [
      org.springframework.context.support.DefaultMessageSourceResolvable: 
          codes [User.club,club]; 
          arguments []; 
          default message [club]
  ]; 
  default message [must not be null]
  </code></pre>
  <p>And when I try with a bad name it gives me :</p>
  <pre><code>Error in object 'User': 
      codes [UniqueNameInClub.User,UniqueNameInClub]; 
      arguments [
          org.springframework.context.support.DefaultMessageSourceResolvable: 
              codes [User.,]; 
              arguments []; 
              default message []
      ]; 
      default message [must be unique]
  </code></pre>
  <p>So much data is missing... Do you have an idea ?</p>
  <p>Thank you so much !</p>
  <p>Etienne</p>