解析枚举值

This commit is contained in:
2025-02-13 18:27:31 +08:00
parent 7307c85cfd
commit f1c0e473f4
3 changed files with 18 additions and 4 deletions

View File

@ -31,6 +31,20 @@ func (r validateRule) IsRequired(structField reflect.StructField) bool {
return exist
}
// Enum 获取枚举值
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 17:23 2025/2/13
func (r validateRule) Enum(structField reflect.StructField) []string {
ruleTable := r.getValidateRuleTable(structField)
oneOfValue, _ := ruleTable[consts.ValidatorRuleCommonOneOf.String()]
if len(oneOfValue) == 0 {
return []string{}
}
return strings.Split(oneOfValue, " ")
}
// getValidateRuleTable 解析验证规则表
//
// Author : go_developer@163.com<白茶清欢>