spring boot Java验证bean:验证枚举字段值
我习惯使用验证规则来检查我的rest参数:
public class ConfigurationParameterForm {
private @NotEmpty String name;
private @NotNull Object value;
private @NotEmpty String beanProperty;
private @NotEmpty String type;
}
当type
字段必须是以下枚举值之一时:
public enum ParameterType {
A("API"), B("BackOffice"), F("FrontOffice"), Q("Quartz"), S("Servlet");
private String description;
ParameterType(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
}
所以,我想检查一下type
是否只包含有效值,我的意思是A
,B
,F
,Q
,S
有什么想法吗
共 (0) 个答案