Hello team, Sorry to trouble you about my problem. I‘m not sure it's a single case or a most popular case on this version. Below are the dependencies and env:

  • java version: SE 8.0
  • boot version: 2.7.14
  • springfox-swagger2 && springfox-swagger-ui: 2.7.0
  • spring security starter
  • javax.validation: 2.0.1.Final
  • spring-boot-starter-validation

Entity define as below:

@ApiModel
@Data
@Validated
public class ClientLoginForm implements Serializable {
    private static final long serialVersionUID = 1L;

    @NotBlank(message = "account cannot be blank")
//    @ApiModelProperty(value = "账号", required = true)
    private String username;

    @NotBlank(message = "password cannot be blank")
//    @ApiModelProperty(value = "密码", required = true)
    private String password;

    @NotBlank(message = "captcha cannot be blank")
//    @ApiModelProperty(value = "验证码", required = true)
    private String captcha;

    @NotBlank(message = "uuid cannot be blank")
    @NotNull
//    @ApiModelProperty(value = "uuid", required = true)
    private String uuid;

}

Net work path as below, when visit this path with null property(’uuid‘) it not throw validation Exception but process as normal, and the visitor get a normal repsonse :

@PostMapping("/signIn")
@ApiOperation(value = "登录", httpMethod = "POST")
R login(@RequestBody @Valid ClientLoginForm form, HttpServletRequest request)

Did anyone encounter this problem before?

Comment From: wilkinsona

I can't see anything obviously wrong. @Valid or @Validated on a control method argument should be sufficient for it to be validated. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: DawsonWang206

Hello, Today I prepare a demo project for this, tested validation worked. Then I tested previous projects which found abnormal validation; validation worked too. I do nothing for them. I don't know why. orz....., Sorry to trouble you and many thanks for your valued help.