增加验证规则复用

This commit is contained in:
QM303176530
2020-05-10 16:21:00 +08:00
parent 760a242118
commit bf4344323d
9 changed files with 89 additions and 122 deletions
+14
View File
@@ -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"