javax 约束的验证问题

Validation issue with javax constraint

在 spring 引导应用程序中,我有一个实体,我在其中放置了一些注释验证。

@Max(value = 17)
private String currency;

@Max(value = 1)
private String freq;

@Max(value = 2)
private String compliance;
 
@Max(value = 1)
private String payment;

@Max(value = 1)
private String wallet;

@Max(value = 2)
private String cycle;

@Max(value = 24)
private String histoProfil;

@Max(value = 20)
private String idNo;

@Max(value = 2)
private String special;

这些文件的价值

freq="M";
compliance="";
currency="";
payment="";
wallet="O";
cycle="19"
histoProfil="";
idNo="Staple Bill";
special="";

我遇到很多错误

for freq: must be lower than or equal to 1
for currency: must be lower than or equal to 17
for compliance: must be lower than or equal to 2
for payment: must be lower than or equal to 1
for wallet: must be lower than or equal to 1
for cycle: : must be lower than or equal to 2
for histoProfil: must be lower than or equal to 24
for idNo: must be lower than or equal to 20
for special: must be lower than or equal to 2

Freq 有一个字符,为什么我会收到此消息? 货币的空值低于 17..

我不明白为什么会出现这个错误。

@Max 注释是对这些类型的验证:BigDecimal、BigInteger、byte、short、int、long 及其各自的包装。

https://docs.oracle.com/javaee/6/api/javax/validation/constraints/Max.html

如果您尝试验证字符串长度,请使用不同的注释@Length(min, max)。