表单验证注解

Form Validator

说明

默认使用的是hibernate-validator框架进行的表单验证,但是有些时候仍然满足不了,就扩展了几个插件,具体请看:

smartadmin.common.validator

CheckEnum

枚举值的校验

public class FileAddDTO { @ApiModelPropertyEnum(enumDesc = "文件类型",value = FileServiceTypeEnum.class) @CheckEnum(enumClazz = FileServiceTypeEnum.class,required = true,message = "文件类型错误") private Integer fileLocationType; @ApiModelProperty("文件名称") @NotBlank(message = "文件名称不能为空") private String fileName; @ApiModelProperty("文件路径") @NotBlank(message = "文件路径不能为空") private String filePath; }

tips:@CheckEnum 同时支持List集合多个枚举值的校验

@CheckEnum(enumClazz = FileServiceTypeEnum.class,required = true,message = "文件类型错误") private List<Integer> fileLocationTypeList;

CheckBigDecimal

校验BigDecimal类型的值

@CheckBigDecimal(value = "0", symbolEnum = ComparisonSymbolEnum.GREATER_THAN_OR_EQUAL, message = "price必须等于大于0") private BigDecimal price;