1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-10 00:29:01 +02:00

delete validate 'required' string

This commit is contained in:
wuxingzhong 2020-03-09 23:50:42 +08:00
parent f3bb1b1ee0
commit f18a1b713f

View File

@ -321,15 +321,13 @@ func getValidateComment(field *descriptor.FieldDescriptorProto) string {
var (
tags []reflect.StructTag
)
comment := ""
//get required info from gogoproto.moretags
moretags := tag.GetMoreTags(field)
if moretags != nil {
tags = []reflect.StructTag{reflect.StructTag(*moretags)}
}
validateTag := tag.GetTagValue("validate", tags)
if len(validateTag) > 0 {
comment = validateTag
}
re, _ := regexp.Compile("required *,*")
comment := re.ReplaceAllString(validateTag, "")
return comment
}