40 lines
802 B
Go
40 lines
802 B
Go
// Package v10 ...
|
|
//
|
|
// Description : v10 ...
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2025-01-24 17:29
|
|
package v10
|
|
|
|
import (
|
|
"fmt"
|
|
"git.zhangdeman.cn/gateway/validator/v10/define"
|
|
"git.zhangdeman.cn/zhangdeman/consts"
|
|
"testing"
|
|
)
|
|
|
|
func TestValidateDynamicStruct(t *testing.T) {
|
|
err := ValidateDynamicStruct(map[string]any{
|
|
"name": "zhang",
|
|
"age": 15,
|
|
}, map[string]define.FieldValidateGenerateConfig{
|
|
"name": {
|
|
Field: "name",
|
|
RuleGroup: nil,
|
|
RuleSimple: define.GenerateRuleExpressConfig{
|
|
Rule: consts.ValidatorRuleCommonRequired,
|
|
},
|
|
},
|
|
"age": {
|
|
Field: "age",
|
|
RuleGroup: nil,
|
|
RuleSimple: define.GenerateRuleExpressConfig{
|
|
Rule: consts.ValidatorRuleCommonMax,
|
|
ParamList: []any{17},
|
|
},
|
|
},
|
|
})
|
|
fmt.Println(err)
|
|
}
|