You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
441 B
17 lines
441 B
package cc |
|
|
|
const enumTpl = ` |
|
{{ $f := .Field }}{{ $r := .Rules }} |
|
{{ template "const" . }} |
|
{{ template "in" . }} |
|
|
|
{{ if $r.GetDefinedOnly }} |
|
{{ if or $f.Type.IsRepeated $f.Type.IsMap }} |
|
if (!{{ class $f.Type.Element.Enum }}_IsValid({{ accessor . }})) { |
|
{{ else }} |
|
if (!{{ class $f.Type.Enum }}_IsValid({{ accessor . }})) { |
|
{{ end }} |
|
{{ err . "value must be one of the defined enum values" }} |
|
} |
|
{{ end }} |
|
`
|
|
|