repeated.go 829 B

123456789101112131415161718192021222324
  1. package java
  2. const repeatedConstTpl = `{{ renderConstants (.Elem "" "") }}`
  3. const repeatedTpl = `{{ $f := .Field }}{{ $r := .Rules -}}
  4. {{- if $r.GetIgnoreEmpty }}
  5. if ( !{{ accessor . }}.isEmpty() ) {
  6. {{- end -}}
  7. {{- if $r.GetMinItems }}
  8. io.envoyproxy.pgv.RepeatedValidation.minItems("{{ $f.FullyQualifiedName }}", {{ accessor . }}, {{ $r.GetMinItems }});
  9. {{- end -}}
  10. {{- if $r.GetMaxItems }}
  11. io.envoyproxy.pgv.RepeatedValidation.maxItems("{{ $f.FullyQualifiedName }}", {{ accessor . }}, {{ $r.GetMaxItems }});
  12. {{- end -}}
  13. {{- if $r.GetUnique }}
  14. io.envoyproxy.pgv.RepeatedValidation.unique("{{ $f.FullyQualifiedName }}", {{ accessor . }});
  15. {{- end }}
  16. io.envoyproxy.pgv.RepeatedValidation.forEach({{ accessor . }}, item -> {
  17. {{ render (.Elem "item" "") }}
  18. });
  19. {{- if $r.GetIgnoreEmpty }}
  20. }
  21. {{- end -}}
  22. `