增加验证规则复用
This commit is contained in:
@@ -9,6 +9,20 @@ import (
|
||||
|
||||
type Rules map[string][]string
|
||||
|
||||
type RulesMap map[string]Rules
|
||||
|
||||
var CustomizeMap = make(map[string]Rules)
|
||||
|
||||
// 注册自定义规则方案建议在路由初始化层即注册
|
||||
func RegisterRule(key string, rule Rules) (err error) {
|
||||
if CustomizeMap[key] != nil {
|
||||
return errors.New(key + "已注册,无法重复注册")
|
||||
} else {
|
||||
CustomizeMap[key] = rule
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// 非空 不能为其对应类型的0值
|
||||
func NotEmpty() string {
|
||||
return "notEmpty"
|
||||
|
||||
Reference in New Issue
Block a user