@Target(value={FIELD,METHOD}) @Retention(value=RUNTIME) @Repeatable(value=Constraints.class) @Documented public @interface Constraint
`@Constraints({
`@Constraint(field = "name", notBlank = true, maxLen = 64),
`@Constraint(field = "type", series = { 1, 2 })
})
or
`@Constraint(notBlank = true, maxLen = 64)
private String name;
参数约束| 限定符和类型 | 可选元素和说明 |
|---|---|
String |
datePattern
日期格式(只针对CharSequence)
|
double |
decimalMax
最大值(只针对浮点数)
the decimalMax value cannot supported Double.POSITIVE_INFINITY
|
double |
decimalMin
最小值(只针对浮点数)
the decimalMin value cannot supported Double.NEGATIVE_INFINITY
|
String |
field
基本数据类型参数不用设值,对象类型参数为字段名
|
int |
index
参数索引位置(第一个参数为0,第二个参数为1,...
|
long |
max
最大值(只针对整数)
the max value cannot supported Long.MAX_VALUE
|
int |
maxLen
最大长度(只针对CharSequence)
|
long |
min
最小值(只针对整数)
the max value cannot supported Long.MIN_VALUE
|
int |
minLen
最小长度(只针对CharSequence)
|
String |
msg
校验失败时的提示信息(不设置时自动拼装为如:orderNo{null}:not allow blank;)
|
boolean |
notBlank
是否不为空白串(只针对CharSequence)
|
boolean |
notEmpty
是否不能为空(只针对CharSequence,Collection,Map,Dictionary,Array)
|
boolean |
notNull
是否不能为null , 为true表示不能为空 , false表示能够为空(对所有类型有效,默认不能为空)
|
String |
regExp
正则验证(只针对CharSequence)
|
long[] |
series
数列
|
Constraint.Tense |
tense
时态(只针对CharSequence[datePattern],Date)
|
public abstract String field
public abstract String msg
public abstract boolean notNull
public abstract boolean notEmpty
public abstract String regExp
public abstract long max
public abstract long min
public abstract String datePattern
public abstract Constraint.Tense tense
Copyright © 2023. All rights reserved.