升级验证库, 支持细化real_map / marshal_map

This commit is contained in:
2024-06-23 11:38:26 +08:00
parent 34962e0cd4
commit 505a41edb5
5 changed files with 67 additions and 15 deletions

10
run.go
View File

@ -228,6 +228,16 @@ func validate(sourceData []byte, val gjson.Result, rule *define.FieldRule) (any,
//
// Date : 14:43 2024/4/29
func handleData(inputVal any, rule *define.FieldRule) (any, error) {
rule.Type = strings.ToLower(rule.Type)
// 处理真实的map和序列化之后的map
if strings.HasPrefix(rule.Type, "map") {
if strings.HasSuffix(rule.Type, "_marshal") {
rule.MapConfig = &define.MapConfig{Mode: consts.DataMapModelMarshal}
} else {
rule.MapConfig = &define.MapConfig{Mode: consts.DataMapModelReal}
}
}
switch rule.Type {
case consts.DataTypeAny: // 任意类型
return inputVal, nil