Skip to content

using multiple validation on same attribute and stop on first failure #35927

@prafullazee

Description

@prafullazee

Java: 20
Springboot: 3.0.1

   @NotBlank(message = "userId id can not be blank.")
   @NotEmpty(message = "userId id can not be empty.")
   @UUID
   @User
   private String userId;

now in request, I am not passing userId, I am getting any of the 4 validation error, but I am expecting, it should fail in the first validation(@NotBlank) itself.

I tried using GroupSequence like

    @GroupSequence({Blank.class, Null.class, Empty.class, Custom.class, UserRequest.class})
      @UserType
      class UserRequest {
          @NotEmpty(groups = Empty.class, message = "userId id can not be empty.")
          @NotBlank(groups = Blank.class, message = "userId id can not be blank.")
          @NotNull(groups = Null.class, message = "userId id can not be null.")
          @UUID(groups = UID.class)
          @User(groups = Custom.class)
          private String userId;
      }

Still randomly error message is coming, it should first give Blank error message, then Null, then empty, then UUID, then custom.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fixstatus: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions