Skip to content

Commit

Permalink
test(controller): test jsr valid
Browse files Browse the repository at this point in the history
  • Loading branch information
chenqi146 committed Apr 23, 2022
1 parent a28f0d6 commit bbec774
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ public CommonResult login(@Validated({Collect.SendCode.class}) @RequestBody Coll
}


/**
* 分组验证4
* @param collect
* @return
*/
@PostMapping("/test4")
public Object test4(@Validated({Collect.SendCode.class}) @RequestBody Collect collect){
return CommonResult.ok();
}


/**
* 测试父级内部注解分组校验
* @param collect
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/power/doc/entity/valid/Collect.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Size;

/**
* @author yu 2020/1/27.
Expand All @@ -18,12 +19,13 @@ public class Collect extends BaseValid {
* 主键id
*/
@Null(groups = {SaveAction.class}, message = "id必须为空")
@NotNull(groups = {Login.class}, message = "id不能为空")
@NotNull(groups = {Login.class, SendCode.class}, message = "id不能为空")
private Long id;

/**
* 名称
*/
@NotBlank(groups = {SaveAction.class}, message = "名称不能为空")
private String name;

/**
Expand Down

0 comments on commit bbec774

Please sign in to comment.