升级验证库, 支持细化real_map / marshal_map
This commit is contained in:
10
run.go
10
run.go
@ -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
|
||||
|
Reference in New Issue
Block a user