修复数组最大长度验证的BUG

This commit is contained in:
白茶清欢 2024-05-16 20:44:20 +08:00
parent 5396616b24
commit 2d8d05044c

View File

@ -286,7 +286,7 @@ func validateSlice(anySlice []any, rule *define.FieldRule) error {
return fmt.Errorf("%v : data type is slice, min length is [%v], real length is [%v]", rule.Path, *rule.ValueLimit.Min, len(anySlice)) return fmt.Errorf("%v : data type is slice, min length is [%v], real length is [%v]", rule.Path, *rule.ValueLimit.Min, len(anySlice))
} }
if nil != rule.ValueLimit.Max && float64(len(anySlice)) > *rule.ValueLimit.Min { if nil != rule.ValueLimit.Max && float64(len(anySlice)) > *rule.ValueLimit.Max {
return fmt.Errorf("%v : data type is slice, max length is [%v], real length is [%v]", rule.Path, *rule.ValueLimit.Max, len(anySlice)) return fmt.Errorf("%v : data type is slice, max length is [%v], real length is [%v]", rule.Path, *rule.ValueLimit.Max, len(anySlice))
} }