七月迭代短暂完结,还有很多后端的关键东西没有弄,这是一版赶时间做的东西
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s
This commit is contained in:
@@ -28,6 +28,7 @@ type Definition struct {
|
||||
EnumValues []string
|
||||
Min *int64
|
||||
Max *int64
|
||||
Validator func(string) error
|
||||
}
|
||||
|
||||
// Registry 保存可写配置的代码权威定义。
|
||||
@@ -127,12 +128,19 @@ func ValidateValue(definition Definition, value string) error {
|
||||
return stderrors.New("系统配置类型不受支持")
|
||||
}
|
||||
if len(definition.EnumValues) > 0 {
|
||||
matched := false
|
||||
for _, allowed := range definition.EnumValues {
|
||||
if value == allowed {
|
||||
return nil
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
}
|
||||
return stderrors.New("系统配置值不在允许枚举中")
|
||||
if !matched {
|
||||
return stderrors.New("系统配置值不在允许枚举中")
|
||||
}
|
||||
}
|
||||
if definition.Validator != nil {
|
||||
return definition.Validator(value)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user