定义了一些SpringMVC
通用的参数校验注解,轻松实现入参的校验,提高接口的健壮性,避免生成一些不必要的脏数据
<repository>
<id>ease-maven</id>
<url>https://code4everything.gitee.io/repository/maven</url>
</repository>
<dependency>
<groupId>org.code4everything</groupId>
<artifactId>validator</artifactId>
<version>1.0.0</version>
</dependency>
@Data
public class BodyVO {
@Chinese(has = true)
private String chinese;
@EndWith("suffix")
private String suffix;
}
@RestController
public class TestController {
@GetMapping("/validation/body")
public String validateBody(@Valid @RequestBody BodyVO bodyVO) {
return "success";
}
}
@Validated
@RestController
public class TestController {
@GetMapping("/validation/body")
public String validateQueryString(@Letter(lowerCase = true) String letter, @Mobile String phoneNumber) {
return "success";
}
}