any.go 544 B

1234567891011121314151617
  1. package cc
  2. const anyTpl = `{{ $f := .Field }}{{ $r := .Rules }}
  3. {{ template "required" . }}
  4. {{ if $r.In }}
  5. {{ $table := lookup $f "InLookup" }}
  6. if ({{ hasAccessor . }} && {{ $table }}.find({{ accessor . }}.type_url()) == {{ $table }}.end()) {
  7. {{ err . "type URL must be in list " $r.In }}
  8. }
  9. {{ else if $r.NotIn }}
  10. {{ $table := lookup $f "NotInLookup" }}
  11. if ({{ hasAccessor . }} && {{ $table }}.find({{ accessor . }}.type_url()) != {{ $table }}.end()) {
  12. {{ err . "type URL must not be in list " $r.NotIn }}
  13. }
  14. {{ end }}
  15. `