2024-04-29 14:08:50 +08:00
|
|
|
// Package validator ...
|
|
|
|
//
|
|
|
|
// Description : validator ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 2024-04-29 12:18
|
|
|
|
package validator
|
|
|
|
|
|
|
|
import "git.zhangdeman.cn/gateway/validator/define"
|
|
|
|
|
|
|
|
// NewDefaultFieldRule ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 14:01 2024/4/29
|
|
|
|
func NewDefaultFieldRule(path string, dataType string, isRequired bool, defaultValue string) *define.FieldRule {
|
|
|
|
r := &define.FieldRule{
|
|
|
|
Path: path,
|
|
|
|
Type: dataType,
|
|
|
|
DefaultValue: defaultValue,
|
|
|
|
IsRequired: isRequired,
|
|
|
|
AllowNil: false,
|
|
|
|
AllowEmpty: false,
|
|
|
|
AllowZero: true,
|
|
|
|
RequiredConditionGroup: make([][]define.RequiredCondition, 0),
|
|
|
|
ValueLimit: &define.ValueLimit{
|
2024-04-29 17:29:46 +08:00
|
|
|
EnumList: make([]string, 0),
|
|
|
|
Min: nil,
|
|
|
|
Max: nil,
|
|
|
|
String: &define.StringValueLimit{
|
|
|
|
AutoTrimSpace: true,
|
|
|
|
IncludeSubStrList: make([]string, 0),
|
|
|
|
},
|
|
|
|
Map: &define.MapValueLimit{IncludeFieldList: make([]string, 0)},
|
2024-04-29 14:08:50 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
return r
|
|
|
|
}
|