text stringlengths 24 1.04M | metadata stringlengths 233 497 |
|---|---|
### File: module/validate.go
package module
import (
"github.com/envoyproxy/protoc-gen-validate/templates"
"github.com/envoyproxy/protoc-gen-validate/templates/java"
pgs "github.com/lyft/protoc-gen-star"
pgsgo "github.com/lyft/protoc-gen-star/lang/go"
)
const (
validatorName = "validator"
langParam = "lang"... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "module/validate.go", "license": "apache-2.0", "size": 1983} |
### File: templates/BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["pkg.go"],
importpath = "github.com/envoyproxy/protoc-gen-validate/templates",
visibility = ["//visibility:public"],
deps = [
"//templates/cc:go_default_libr... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/BUILD.bazel", "license": "apache-2.0", "size": 581} |
### File: templates/cc/BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"any.go",
"bytes.go",
"const.go",
"duration.go",
"enum.go",
"file.go",
"in.go",
"known.go",
"ltgt.go"... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/BUILD.bazel", "license": "apache-2.0", "size": 1079} |
### File: templates/cc/any.go
package cc
const anyTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{ template "required" . }}
{{ if $r.In }}
{{ $table := lookup $f "InLookup" }}
if ({{ hasAccessor . }} && {{ $table }}.find({{ accessor . }}.type_url()) == {{ $table }}.end()) {
{{ err . "type URL must be in list "... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/any.go", "license": "apache-2.0", "size": 544} |
### File: templates/cc/bytes.go
package cc
const bytesTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
{{ template "const" . }}
{{ template "in" . }}
{{ if or $r.Len (and $r.MinLen $r.MaxLen (eq $r.GetMinLen $r.GetMaxLen)) }}
{
const auto length = {{ accessor . }}.size();
{{ if $r.Len }}
if (length != {{ $r.G... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/bytes.go", "license": "apache-2.0", "size": 2816} |
### File: templates/cc/const.go
package cc
const constTpl = `{{ $r := .Rules }}
{{ if $r.Const }}
if ({{ accessor . }} != {{ lit $r.GetConst }}) {
{{ err . "value must equal " $r.GetConst }}
}
{{ end }}
`
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/const.go", "license": "apache-2.0", "size": 183} |
### File: templates/cc/duration.go
package cc
const durationTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{ template "required" . }}
{{ if or $r.In $r.NotIn $r.Lt $r.Lte $r.Gt $r.Gte $r.Const }}
{
if ({{ hasAccessor . }}) {
const pgv::protobuf_wkt::Duration& dur = {{ accessor . }};
if (dur.nanos... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/duration.go", "license": "apache-2.0", "size": 3336} |
### File: templates/cc/enum.go
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... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/enum.go", "license": "apache-2.0", "size": 441} |
### File: templates/cc/in.go
package cc
const inTpl = `{{ $f := .Field -}}{{ $r := .Rules -}}
{{- if $r.In }}
if ({{ lookup $f "InLookup" }}.find(static_cast<decltype({{ lookup $f "InLookup" }})::key_type>({{ accessor . }})) == {{ lookup $f "InLookup" }}.end()) {
{{ err . "value must be in list " $r.In }}
}
{... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/in.go", "license": "apache-2.0", "size": 550} |
### File: templates/cc/known.go
package cc
const hostTpl = `
func (m {{ .TypeName.Pointer }}) _validateHostname(host string) error {
s := strings.TrimSuffix(host, ".")
if len(host) > 253 {
return errors.New("hostname cannot exceed 253 characters")
}
for _, part := range strings.Split(s, ".") {
if l :=... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/known.go", "license": "apache-2.0", "size": 1634} |
### File: templates/cc/ltgt.go
package cc
const ltgtTpl = `{{ $f := .Field }}{{ $r := .Rules }}{{ $v := (accessor .) }}
{{ if $r.Lt }}
{{ if $r.Gt }}
{{ if gt $r.GetLt $r.GetGt }}
if ({{ $v }} <= {{ $r.Gt }} || {{ $v }} >= {{ $r.Lt }}) {
{{ err . "value must be inside range (" $r.GetGt ", " $r.GetLt ")... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/ltgt.go", "license": "apache-2.0", "size": 2139} |
### File: templates/cc/map.go
package cc
const mapTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
{{ if $r.GetMinPairs }}
{
const auto size = {{ accessor . }}.size();
{{ if eq $r.GetMinPairs $r.GetMaxPairs }}
if (size != {{ $r.GetMinPairs }}) {
{{ err . "value must contain exactly " $r.GetMinPairs " pair(... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/map.go", "license": "apache-2.0", "size": 1330} |
### File: templates/cc/message.go
package cc
const messageTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
{{ template "required" . }}
{{ if .MessageRules.GetSkip }}
// skipping validation for {{ $f.Name }}
{{ else }}
{
pgv::ValidationMsg inner_err;
if ({{ hasAccessor .}} && !pgv::Validator<{{ ctype $f.Type }}>... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/message.go", "license": "apache-2.0", "size": 557} |
### File: templates/cc/msg.go
package cc
const declTpl = `
{{ if not (ignored .) -}}
extern bool Validate(const {{ class . }}& m, pgv::ValidationMsg* err);
{{- end -}}
`
const msgTpl = `
{{ if not (ignored .) -}}
{{ if disabled . -}}
{{ cmt "Validate is disabled for " (class .) ". This method will always return true... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/msg.go", "license": "apache-2.0", "size": 4378} |
### File: templates/cc/none.go
package cc
const noneTpl = `// no validation rules for {{ .Field.Name }}
{{- if .Index }}[{{ .Index }}]{{ end }}
{{- if .OnKey }} (key){{ end }}`
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/none.go", "license": "apache-2.0", "size": 149} |
### File: templates/cc/num.go
package cc
const numTpl = `
{{ template "const" . }}
{{ template "ltgt" . }}
{{ template "in" . }}
`
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/num.go", "license": "apache-2.0", "size": 105} |
### File: templates/cc/register.go
package cc
import (
"fmt"
"reflect"
"strconv"
"strings"
"text/template"
"github.com/envoyproxy/protoc-gen-validate/templates/shared"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/duration"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/i... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/register.go", "license": "apache-2.0", "size": 11569} |
### File: templates/cc/repeated.go
package cc
const repTpl = `
{{ $f := .Field }}{{ $r := .Rules }}{{ $typ := inType $f nil }}
{{ if $r.GetMinItems }}
{{ if eq $r.GetMinItems $r.GetMaxItems }}
if ({{ accessor . }}.size() != {{ $r.GetMinItems }}) {
{{ err . "value must contain exactly " $r.GetMinItems " ite... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/repeated.go", "license": "apache-2.0", "size": 1947} |
### File: templates/cc/string.go
package cc
const strTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
{{ template "const" . }}
{{ template "in" . }}
{{ if or $r.Len (and $r.MinLen $r.MaxLen (eq $r.GetMinLen $r.GetMaxLen)) }}
{{ if $r.Len }}
if (pgv::Utf8Len({{ accessor . }}) != {{ $r.GetLen }}) {
{{ err . "va... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/string.go", "license": "apache-2.0", "size": 5430} |
### File: templates/cc/timestamp.go
package cc
const timestampTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{ template "required" . }}
{{ if or $r.Lt $r.Lte $r.Gt $r.Gte $r.LtNow $r.GtNow $r.Within $r.Const }}
{{ unimplemented "C++ timestamp comparison validations are not implemented" }}
{{/*
if t := {{ access... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/timestamp.go", "license": "apache-2.0", "size": 3845} |
### File: templates/cc/wrapper.go
package cc
const wrapperTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
if ({{ hasAccessor . }}) {
const auto wrapped = {{ accessor . }};
{{ render (unwrap . "wrapped") }}
} {{ if .MessageRules.GetRequired }} else {
{{ err . "value is required and must not be nil." }}
} {{ end... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/cc/wrapper.go", "license": "apache-2.0", "size": 292} |
### File: templates/go/BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"duration.go",
"file.go",
"message.go",
"register.go",
"required.go",
"timestamp.go",
],
importpath = "github.com/env... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/go/BUILD.bazel", "license": "apache-2.0", "size": 508} |
### File: templates/go/duration.go
package golang
const durationTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{ template "required" . }}
{{ if or $r.In $r.NotIn $r.Lt $r.Lte $r.Gt $r.Gte $r.Const }}
if d := {{ accessor . }}; d != nil {
dur, err := ptypes.Duration(d)
if err != nil { return {{ errCause . "err"... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/go/duration.go", "license": "apache-2.0", "size": 375} |
### File: templates/go/message.go
package golang
const messageTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
{{ template "required" . }}
{{ if .MessageRules.GetSkip }}
// skipping validation for {{ $f.Name }}
{{ else }}
if v, ok := interface{}({{ accessor . }}).(interface{ Validate() error }); ok {
if err :=... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/go/message.go", "license": "apache-2.0", "size": 407} |
### File: templates/go/register.go
package golang
import (
"text/template"
"github.com/lyft/protoc-gen-star"
"github.com/envoyproxy/protoc-gen-validate/templates/goshared"
)
func Register(tpl *template.Template, params pgs.Parameters) {
goshared.Register(tpl, params)
template.Must(tpl.Parse(fileTpl))
template.... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/go/register.go", "license": "apache-2.0", "size": 497} |
### File: templates/go/required.go
package golang
const requiredTpl = `
{{ if .Rules.GetRequired }}
if {{ accessor . }} == nil {
return {{ err . "value is required" }}
}
{{ end }}
`
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/go/required.go", "license": "apache-2.0", "size": 157} |
### File: templates/go/timestamp.go
package golang
const timestampTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{ template "required" . }}
{{ if or $r.Lt $r.Lte $r.Gt $r.Gte $r.LtNow $r.GtNow $r.Within $r.Const }}
if t := {{ accessor . }}; t != nil {
ts, err := ptypes.Timestamp(t)
if err != nil { return {{ e... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/go/timestamp.go", "license": "apache-2.0", "size": 391} |
### File: templates/goshared/BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"any.go",
"bytes.go",
"const.go",
"duration.go",
"enum.go",
"in.go",
"known.go",
"ltgt.go",
"ma... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/BUILD.bazel", "license": "apache-2.0", "size": 1044} |
### File: templates/goshared/any.go
package goshared
const anyTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{ template "required" . }}
if a := {{ accessor . }}; a != nil {
{{ if $r.In }}
if _, ok := {{ lookup $f "InLookup" }}[a.GetTypeUrl()]; !ok {
return {{ err . "type URL must be in list " $r.In }}
}
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/any.go", "license": "apache-2.0", "size": 461} |
### File: templates/goshared/bytes.go
package goshared
const bytesTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
{{ if or $r.Len (and $r.MinLen $r.MaxLen (eq $r.GetMinLen $r.GetMaxLen)) }}
{{ if $r.Len }}
if len({{ accessor . }}) != {{ $r.GetLen }} {
return {{ err . "value length must be " $r.GetLen " bytes"... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/bytes.go", "license": "apache-2.0", "size": 2641} |
### File: templates/goshared/const.go
package goshared
const constTpl = `{{ $r := .Rules }}
{{ if $r.Const }}
if {{ accessor . }} != {{ lit $r.GetConst }} {
return {{ err . "value must equal " $r.GetConst }}
}
{{ end }}
`
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/const.go", "license": "apache-2.0", "size": 194} |
### File: templates/goshared/duration.go
package goshared
const durationcmpTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{ if $r.Const }}
if dur != {{ durLit $r.Const }} {
return {{ err . "value must equal " (durStr $r.Const) }}
}
{{ end }}
{{ if $r.Lt }} lt := {{ durLit $r.Lt }}; {{ end }}... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/duration.go", "license": "apache-2.0", "size": 2866} |
### File: templates/goshared/enum.go
package goshared
const enumTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
{{ template "const" . }}
{{ template "in" . }}
{{ if $r.GetDefinedOnly }}
if _, ok := {{ (typ $f).Element }}_name[int32({{ accessor . }})]; !ok {
return {{ err . "value must be one of the define... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/enum.go", "license": "apache-2.0", "size": 320} |
### File: templates/goshared/in.go
package goshared
const inTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{ if $r.In }}
if _, ok := {{ lookup $f "InLookup" }}[{{ accessor . }}]; !ok {
return {{ err . "value must be in list " $r.In }}
}
{{ else if $r.NotIn }}
if _, ok := {{ lookup $f "NotInLookup" }}[{{ acces... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/in.go", "license": "apache-2.0", "size": 378} |
### File: templates/goshared/known.go
package goshared
const hostTpl = `
func (m {{ (msgTyp .).Pointer }}) _validateHostname(host string) error {
s := strings.ToLower(strings.TrimSuffix(host, "."))
if len(host) > 253 {
return errors.New("hostname cannot exceed 253 characters")
}
for _, part := range stri... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/known.go", "license": "apache-2.0", "size": 1607} |
### File: templates/goshared/ltgt.go
package goshared
const ltgtTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{ if $r.Lt }}
{{ if $r.Gt }}
{{ if gt $r.GetLt $r.GetGt }}
if val := {{ accessor . }}; val <= {{ $r.Gt }} || val >= {{ $r.Lt }} {
return {{ err . "value must be inside range (" $r.GetGt ", " $r... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/ltgt.go", "license": "apache-2.0", "size": 2305} |
### File: templates/goshared/map.go
package goshared
const mapTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
{{ if $r.GetMinPairs }}
{{ if eq $r.GetMinPairs $r.GetMaxPairs }}
if len({{ accessor . }}) != {{ $r.GetMinPairs }} {
return {{ err . "value must contain exactly " $r.GetMinPairs " pair(s)" }}
}
{... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/map.go", "license": "apache-2.0", "size": 1239} |
### File: templates/goshared/msg.go
package goshared
const msgTpl = `
{{ if not (ignored .) -}}
{{ if disabled . -}}
{{ cmt "Validate is disabled for " (msgTyp .) ". This method will always return nil." }}
{{- else -}}
{{ cmt "Validate checks the field values on " (msgTyp .) " with the rules defined in the proto def... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/msg.go", "license": "apache-2.0", "size": 5066} |
### File: templates/goshared/none.go
package goshared
const noneTpl = `// no validation rules for {{ name .Field }}
{{- if .Index }}[{{ .Index }}]{{ end }}
{{- if .OnKey }} (key){{ end }}`
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/none.go", "license": "apache-2.0", "size": 155} |
### File: templates/goshared/num.go
package goshared
const numTpl = `
{{ template "const" . }}
{{ template "ltgt" . }}
{{ template "in" . }}
`
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/num.go", "license": "apache-2.0", "size": 111} |
### File: templates/goshared/register.go
package goshared
import (
"fmt"
"github.com/iancoleman/strcase"
"reflect"
"strings"
"text/template"
"github.com/envoyproxy/protoc-gen-validate/templates/shared"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/duration"
"github.com/golang/protobu... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/register.go", "license": "apache-2.0", "size": 8459} |
### File: templates/goshared/repeated.go
package goshared
const repTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
{{ if $r.GetMinItems }}
{{ if eq $r.GetMinItems $r.GetMaxItems }}
if len({{ accessor . }}) != {{ $r.GetMinItems }} {
return {{ err . "value must contain exactly " $r.GetMinItems " item(s)" }}
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/repeated.go", "license": "apache-2.0", "size": 1646} |
### File: templates/goshared/string.go
package goshared
const strTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
{{ template "const" . }}
{{ template "in" . }}
{{ if or $r.Len (and $r.MinLen $r.MaxLen (eq $r.GetMinLen $r.GetMaxLen)) }}
{{ if $r.Len }}
if utf8.RuneCountInString({{ accessor . }}) != {{ $r.GetLen ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/string.go", "license": "apache-2.0", "size": 4587} |
### File: templates/goshared/timestamp.go
package goshared
const timestampcmpTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{ if $r.Const }}
if !ts.Equal({{ tsLit $r.Const }}) {
return {{ err . "value must equal " (tsStr $r.Const) }}
}
{{ end }}
{{ if or $r.LtNow $r.GtNow $r.Within }} now := time... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/timestamp.go", "license": "apache-2.0", "size": 3624} |
### File: templates/goshared/wrapper.go
package goshared
const wrapperTpl = `
{{ $f := .Field }}{{ $r := .Rules }}
if wrapper := {{ accessor . }}; wrapper != nil {
{{ render (unwrap . "wrapper") }}
} {{ if .MessageRules.GetRequired }} else {
return {{ err . "value is required and must not be nil." }}
} {{ end... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/goshared/wrapper.go", "license": "apache-2.0", "size": 286} |
### File: templates/java/BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"any.go",
"bool.go",
"bytes.go",
"duration.go",
"enum.go",
"file.go",
"map.go",
"message.go",
"msg.... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/BUILD.bazel", "license": "apache-2.0", "size": 1025} |
### File: templates/java/any.go
package java
const anyConstTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{- if $r.In }}
private final String[] {{ constantName . "In" }} = new String[]{
{{- range $r.In }}
"{{ . }}",
{{- end }}
};
{{- end -}}
{{- if $r.NotIn }}
private final String[] {{ constantName . "Not... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/any.go", "license": "apache-2.0", "size": 859} |
### File: templates/java/bool.go
package java
const boolTpl = `{{ $f := .Field }}{{ $r := .Rules -}}
{{- if $r.Const }}
io.envoyproxy.pgv.ConstantValidation.constant("{{ $f.FullyQualifiedName }}", {{ accessor . }}, {{ $r.GetConst }});
{{- end }}`
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/bool.go", "license": "apache-2.0", "size": 218} |
### File: templates/java/bytes.go
package java
const bytesConstTpl = `{{ $f := .Field }}{{ $r := .Rules -}}
{{- if $r.Const }}
private final com.google.protobuf.ByteString {{ constantName . "Const" }} = com.google.protobuf.ByteString.copyFrom({{ byteArrayLit $r.GetConst }});
{{- end -}}
{{- if $r.In }}
private fin... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/bytes.go", "license": "apache-2.0", "size": 3284} |
### File: templates/java/duration.go
package java
const durationConstTpl = `{{ $f := .Field }}{{ $r := .Rules -}}
{{- if $r.Const }}
private final com.google.protobuf.Duration {{ constantName . "Const" }} = {{ durLit $r.GetConst }};
{{- end -}}
{{- if $r.Lt }}
private final com.google.protobuf.Duration {{ constant... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/duration.go", "license": "apache-2.0", "size": 3213} |
### File: templates/java/enum.go
package java
const enumConstTpl = `{{ $ctx := . }}{{ $f := .Field }}{{ $r := .Rules -}}
{{- if $r.In }}
private final {{ javaTypeFor . }}[] {{ constantName . "In" }} = new {{ javaTypeFor . }}[]{
{{- range $r.In }}
{{ javaTypeFor $ctx }}.forNumber({{- sprintf "%v" . -}}),
{{-... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/enum.go", "license": "apache-2.0", "size": 1235} |
### File: templates/java/map.go
package java
const mapConstTpl = `{{ $f := .Field }}{{ $r := .Rules -}}
{{ if or (ne (.Elem "" "").Typ "none") (ne (.Key "" "").Typ "none") }}
{{ renderConstants (.Key "key" "Key") }}
{{ renderConstants (.Elem "value" "Value") }}
{{- end -}}
`
const mapTpl = `{{ $f := .Field }}{{ $... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/map.go", "license": "apache-2.0", "size": 1079} |
### File: templates/java/message.go
package java
const messageTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{- if .MessageRules.GetSkip }}
// skipping validation for {{ $f.Name }}
{{- else -}}
{{- template "required" . }}
{{- if (isOfMessageType $f) }}
// Validate {{ $f.Name }}
if ({{ hasAccessor . }}) i... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/message.go", "license": "apache-2.0", "size": 380} |
### File: templates/java/msg.go
package java
const msgTpl = `
{{ if not (ignored .) -}}
/**
* Validates {@code {{ simpleName . }}} protobuf objects.
*/
public static class {{ simpleName . }}Validator implements io.envoyproxy.pgv.ValidatorImpl<{{ qualifiedName . }}> {
{{- template "msgInner" . -}}
}
{{- end -}... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/msg.go", "license": "apache-2.0", "size": 839} |
### File: templates/java/none.go
package java
const noneTpl = `// no validation rules for {{ simpleName .Field }}
`
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/none.go", "license": "apache-2.0", "size": 84} |
### File: templates/java/num.go
package java
const numConstTpl = `{{ $f := .Field }}{{ $r := .Rules -}}
{{- if $r.Const }}
private final {{ javaTypeFor .}} {{ constantName . "Const" }} = {{ $r.GetConst }}{{ javaTypeLiteralSuffixFor . }};
{{- end -}}
{{- if $r.Lt }}
private final {{ javaTypeFor .}} {{ constantName ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/num.go", "license": "apache-2.0", "size": 3037} |
### File: templates/java/oneof.go
package java
const oneOfConstTpl = `
{{ range .Fields }}{{ renderConstants (context .) }}{{ end }}
`
const oneOfTpl = `
switch (proto.get{{camelCase .Name }}Case()) {
{{ range .Fields -}}
case {{ oneof . }}:
{{ render (context .) }}
break;
{{ end -}}
{{- ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/oneof.go", "license": "apache-2.0", "size": 426} |
### File: templates/java/register.go
package java
import (
"bytes"
"fmt"
"os"
"strings"
"text/template"
"unicode"
"github.com/envoyproxy/protoc-gen-validate/templates/shared"
"github.com/golang/protobuf/ptypes/duration"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/iancoleman/strcase"
pgs "gith... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/register.go", "license": "apache-2.0", "size": 15098} |
### File: templates/java/repeated.go
package java
const repeatedConstTpl = `{{ renderConstants (.Elem "" "") }}`
const repeatedTpl = `{{ $f := .Field }}{{ $r := .Rules -}}
{{- if $r.GetMinItems }}
io.envoyproxy.pgv.RepeatedValidation.minItems("{{ $f.FullyQualifiedName }}", {{ accessor . }}, {{ $r.GetMinItems }});
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/repeated.go", "license": "apache-2.0", "size": 704} |
### File: templates/java/required.go
package java
const requiredTpl = `{{ $f := .Field }}
{{- if .Rules.GetRequired }}
if ({{ hasAccessor . }}) {
io.envoyproxy.pgv.RequiredValidation.required("{{ $f.FullyQualifiedName }}", {{ accessor . }});
} else {
io.envoyproxy.pgv.RequiredValidation.required("{{ $f.Full... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/required.go", "license": "apache-2.0", "size": 330} |
### File: templates/java/string.go
package java
const stringConstTpl = `{{ $f := .Field }}{{ $r := .Rules -}}
{{- if $r.In }}
private final {{ javaTypeFor . }}[] {{ constantName . "In" }} = new {{ javaTypeFor . }}[]{
{{- range $r.In -}}
"{{- sprintf "%v" . -}}",
{{- end -}}
};
{{- end -}}
{{- if $r.NotIn... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/string.go", "license": "apache-2.0", "size": 3983} |
### File: templates/java/timestamp.go
package java
const timestampConstTpl = `{{ $f := .Field }}{{ $r := .Rules -}}
{{- if $r.Const }}
private final com.google.protobuf.Timestamp {{ constantName . "Const" }} = {{ tsLit $r.GetConst }};
{{- end -}}
{{- if $r.Lt }}
private final com.google.protobuf.Timestamp {{ const... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/timestamp.go", "license": "apache-2.0", "size": 3366} |
### File: templates/java/unimplemented.go
package java
const notImplementedTpl = `/* NOT YET IMPLEMENTED */`
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/unimplemented.go", "license": "apache-2.0", "size": 68} |
### File: templates/java/wrapper.go
package java
const wrapperConstTpl = `{{ $f := .Field }}{{ $r := .Rules }}
{{- renderConstants (unwrap .) }}`
const wrapperTpl = `{{ $f := .Field }}{{ $r := .Rules }}
if ({{ hasAccessor . }}) {
{{- render (unwrap .) }}
}
{{ if .MessageRules.GetRequired }} else... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/java/wrapper.go", "license": "apache-2.0", "size": 391} |
### File: templates/pkg.go
package templates
import (
"text/template"
"github.com/lyft/protoc-gen-star"
"github.com/lyft/protoc-gen-star/lang/go"
"github.com/envoyproxy/protoc-gen-validate/templates/cc"
"github.com/envoyproxy/protoc-gen-validate/templates/go"
"github.com/envoyproxy/protoc-gen-validate/templates... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/pkg.go", "license": "apache-2.0", "size": 1426} |
### File: templates/shared/BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"context.go",
"disabled.go",
"functions.go",
"reflection.go",
"well_known.go",
],
importpath = "github.com/envoyproxy/pro... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/shared/BUILD.bazel", "license": "apache-2.0", "size": 560} |
### File: templates/shared/context.go
package shared
import (
"bytes"
"fmt"
"text/template"
"github.com/envoyproxy/protoc-gen-validate/validate"
"github.com/golang/protobuf/proto"
pgs "github.com/lyft/protoc-gen-star"
)
type RuleContext struct {
Field pgs.Field
Rules proto.Message
MessageRules... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/shared/context.go", "license": "apache-2.0", "size": 5268} |
### File: templates/shared/disabled.go
package shared
import (
"github.com/envoyproxy/protoc-gen-validate/validate"
"github.com/lyft/protoc-gen-star"
)
// Disabled returns true if validations are disabled for msg
func Disabled(msg pgs.Message) (disabled bool, err error) {
_, err = msg.Extension(validate.E_Disabled... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/shared/disabled.go", "license": "apache-2.0", "size": 700} |
### File: templates/shared/functions.go
package shared
import (
"text/template"
"github.com/lyft/protoc-gen-star"
)
func RegisterFunctions(tpl *template.Template, params pgs.Parameters) {
tpl.Funcs(map[string]interface{}{
"disabled": Disabled,
"ignored": Ignored,
"required": RequiredOneOf,
"context": ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/shared/functions.go", "license": "apache-2.0", "size": 398} |
### File: templates/shared/reflection.go
package shared
import (
"reflect"
"github.com/golang/protobuf/proto"
)
func extractVal(r proto.Message) reflect.Value {
val := reflect.ValueOf(r)
if val.Kind() == reflect.Interface {
val = val.Elem()
}
if val.Kind() == reflect.Ptr {
val = val.Elem()
}
return va... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/shared/reflection.go", "license": "apache-2.0", "size": 480} |
### File: templates/shared/well_known.go
package shared
import (
"github.com/envoyproxy/protoc-gen-validate/validate"
"github.com/lyft/protoc-gen-star"
)
type WellKnown string
const (
Email WellKnown = "email"
Hostname WellKnown = "hostname"
UUID WellKnown = "uuid"
)
func FileNeeds(f pgs.File, wk WellKn... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "templates/shared/well_known.go", "license": "apache-2.0", "size": 1816} |
### File: tests/generation/multi_file_java_test/BUILD
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
"//bazel:pgv_proto_library.bzl",
"pgv_cc_proto_library",
)
# gazelle:go_generate_proto false
proto_library(
name = "test_proto",
srcs = ["test.p... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/generation/multi_file_java_test/BUILD", "license": "apache-2.0", "size": 658} |
### File: tests/generation/multi_file_java_test/main.cc
#include <iostream>
#include "tests/generation/multi_file_java_test/test.pb.h"
#include "tests/generation/multi_file_java_test/test.pb.validate.h"
int main(int argc, char** argv) {
return 0;
}
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/generation/multi_file_java_test/main.cc", "license": "apache-2.0", "size": 197} |
### File: tests/harness/BUILD
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")
load("@io_b... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/BUILD", "license": "apache-2.0", "size": 1489} |
### File: tests/harness/cases/BUILD
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
"//bazel:pgv_proto_library.bzl",
"pgv_cc_proto_library",
"pgv_go_proto_library",
"pgv_java_proto_library",
"pgv_python_proto_library",
)
# gazelle... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/cases/BUILD", "license": "apache-2.0", "size": 2156} |
### File: tests/harness/cases/other_package/BUILD
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
"//bazel:pgv_proto_library.bzl",
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/cases/other_package/BUILD", "license": "apache-2.0", "size": 2008} |
### File: tests/harness/cc/BUILD
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
MSVC_C_OPTS = [
"-WX",
"-DWIN32",
"-DWIN32_LEAN_AND_MEAN",
]
POSIX_C_OPTS = [
"-Wall",
"-Wextra",
"-Werror",
"-Wnon-virtual-dtor",
"-Woverloaded-virtual",
"-Wold-style-cast",
"... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/cc/BUILD", "license": "apache-2.0", "size": 1743} |
### File: tests/harness/cc/diamond_lib.cc
#include "tests/harness/cases/bool.pb.h"
#include "tests/harness/cases/bool.pb.validate.h"
#include "tests/harness/cases/bytes.pb.h"
#include "tests/harness/cases/bytes.pb.validate.h"
#include "tests/harness/cases/enums.pb.h"
#include "tests/harness/cases/enums.pb.validate.h"
#... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/cc/diamond_lib.cc", "license": "apache-2.0", "size": 1166} |
### File: tests/harness/cc/diamond_test.cc
#include "tests/harness/cases/bool.pb.h"
#include "tests/harness/cases/bool.pb.validate.h"
#include "tests/harness/cases/bytes.pb.h"
#include "tests/harness/cases/bytes.pb.validate.h"
#include "tests/harness/cases/enums.pb.h"
#include "tests/harness/cases/enums.pb.validate.h"
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/cc/diamond_test.cc", "license": "apache-2.0", "size": 1255} |
### File: tests/harness/cc/harness.cc
#include <functional>
#include <iostream>
#if defined(WIN32)
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#endif
#include "validate/validate.h"
#include "tests/harness/cases/bool.pb.h"
#include "tests/harness/cases/bool.pb.validate.h"
#include "tests/harness/cases/bytes... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/cc/harness.cc", "license": "apache-2.0", "size": 5992} |
### File: tests/harness/executor/BUILD
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
config_setting(
name = "windows_x86_64",
values = {"cpu": "x64_windows"},
)
go_library(
name = "go_default_library",
srcs = [
"cases.go",
"executor.go",
"harness.go",
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/executor/BUILD", "license": "apache-2.0", "size": 1568} |
### File: tests/harness/executor/cases.go
package main
import (
"math"
"time"
cases "github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/go"
other_package "github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/other_package/go"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/pt... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/executor/cases.go", "license": "apache-2.0", "size": 87437} |
### File: tests/harness/executor/executor.go
package main
import (
"flag"
"log"
"os"
"runtime"
"sync"
"sync/atomic"
"time"
)
func init() {
log.SetFlags(0)
}
func main() {
parallelism := flag.Int("parallelism", runtime.NumCPU(), "Number of test cases to run in parallel")
goFlag := flag.Bool("go", false, "Ru... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/executor/executor.go", "license": "apache-2.0", "size": 1716} |
### File: tests/harness/executor/harness.go
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"os"
"os/exec"
"runtime"
"sync"
"strings"
harness "github.com/envoyproxy/protoc-gen-validate/tests/harness/go"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
)
func Harnesses(goFlag, ccFlag, javaF... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/executor/harness.go", "license": "apache-2.0", "size": 2781} |
### File: tests/harness/executor/worker.go
package main
import (
"bytes"
"context"
"fmt"
"log"
"sync"
"time"
harness "github.com/envoyproxy/protoc-gen-validate/tests/harness/go"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
)
func Work(wg *sync.WaitGroup, in <-chan TestCase, out cha... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/executor/worker.go", "license": "apache-2.0", "size": 1889} |
### File: tests/harness/go/main/BUILD
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "go_default_library",
srcs = ["harness.go"],
importpath = "github.com/envoyproxy/protoc-gen-validate/tests/harness/go/main",
visibility = ["//visibility:private"],
deps = [
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/go/main/BUILD", "license": "apache-2.0", "size": 1071} |
### File: tests/harness/go/main/harness.go
package main
import (
"fmt"
"github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/go"
"io/ioutil"
"log"
"os"
_ "github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/go"
_ "github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/other_package/go... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/go/main/harness.go", "license": "apache-2.0", "size": 1602} |
### File: tests/harness/java/BUILD
load("@rules_java//java:defs.bzl", "java_binary")
java_binary(
name = "java-harness",
main_class = "io.envoyproxy.pgv.validation.JavaHarness",
visibility = ["//tests/harness:__subpackages__"],
runtime_deps = [
"//java/pgv-java-validation/src/main/java/io/envoy... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/java/BUILD", "license": "apache-2.0", "size": 330} |
### File: tests/harness/python/BUILD
load("@io_bazel_rules_python//python:python.bzl", "py_binary")
load("@pgv_pip_deps//:requirements.bzl", "requirement")
py_binary(
name = "python-harness",
srcs = ["harness.py"],
main = "harness.py",
visibility = ["//tests/harness:__subpackages__"],
deps = [
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/python/BUILD", "license": "apache-2.0", "size": 568} |
### File: tests/harness/python/harness.py
import sys
import inspect
import os
from tests.harness.harness_pb2 import TestCase, TestResult
from tests.harness.cases.bool_pb2 import *
from tests.harness.cases.bytes_pb2 import *
from tests.harness.cases.enums_pb2 import *
from tests.harness.cases.enums_pb2 import *
from te... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tests/harness/python/harness.py", "license": "apache-2.0", "size": 2366} |
### File: tools.go
// +build tools
package main
import (
_ "github.com/golang/protobuf/protoc-gen-go"
_ "golang.org/x/lint/golint"
_ "golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow"
_ "golang.org/x/net/context"
)
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "minhanghuang/protoc-gen-validate", "path": "tools.go", "license": "apache-2.0", "size": 209} |
### File: validate/BUILD
load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_lib... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Starlark", "repo_name": "minhanghuang/protoc-gen-validate", "path": "validate/BUILD", "license": "apache-2.0", "size": 1431} |
### File: validate/validate.h
#ifndef _VALIDATE_H
#define _VALIDATE_H
#include <functional>
#include <regex>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include <typeindex>
#include <unordered_map>
#if !defined(_WIN32)
#include <arpa/inet.h>
#else
#include <winsock2.h>
#include <ws2tcpip.h>
// <windo... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/protoc-gen-validate", "path": "validate/validate.h", "license": "apache-2.0", "size": 4136} |
### File: validate/validator.py
import re
from functools import lru_cache
from validate_email import validate_email
import ipaddress
try:
import urlparse
except ImportError:
import urllib.parse as urlparse
import uuid
import struct
from jinja2 import Template
import time
import sys
printer = ""
# Well known r... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/protoc-gen-validate", "path": "validate/validator.py", "license": "apache-2.0", "size": 43306} |
### File: windows/ci.ps1
$ErrorActionPreference = "Stop";
trap { $host.SetShouldExit(1) }
#bazel-harness
# runs the test harness via bazel
bazel "--output_base=c:\_pgv" "--bazelrc=windows\bazel.rc" run //tests/harness/executor:executor
exit $LASTEXITCODE
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "PowerShell", "repo_name": "minhanghuang/protoc-gen-validate", "path": "windows/ci.ps1", "license": "apache-2.0", "size": 231} |
### File: examples/imagenet_eval.py
from __future__ import print_function, division, absolute_import
import argparse
import os
import shutil
import time
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torchvision.transfo... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pretrained-models.pytorch", "path": "examples/imagenet_eval.py", "license": "bsd-3-clause", "size": 10785} |
### File: examples/imagenet_logits.py
from __future__ import print_function, division, absolute_import
import argparse
from PIL import Image
import torch
import torchvision.transforms as transforms
import sys
sys.path.append('.')
import pretrainedmodels
import pretrainedmodels.utils as utils
model_names = sorted(nam... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pretrained-models.pytorch", "path": "examples/imagenet_logits.py", "license": "bsd-3-clause", "size": 2419} |
### File: examples/visu_arch.py
from __future__ import print_function, division, absolute_import
import os
import torch # http://pytorch.org/about/
from torch.autograd import Variable
from torch.utils import model_zoo
import torchvision # https://github.com/pytorch/vision
import torchvision.models as models
import to... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pretrained-models.pytorch", "path": "examples/visu_arch.py", "license": "bsd-3-clause", "size": 8754} |
### File: examples/voc2007_extract.py
from __future__ import print_function, division, absolute_import
import os
import argparse
from tqdm import tqdm
import torch
from torch.autograd import Variable
from torch.utils import model_zoo
# http://scikit-learn.org
from sklearn.metrics import accuracy_score
from sklearn.me... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pretrained-models.pytorch", "path": "examples/voc2007_extract.py", "license": "bsd-3-clause", "size": 8625} |
### File: pretrainedmodels/__init__.py
from .version import __version__
from . import models
from . import datasets
from .models.utils import pretrained_settings
from .models.utils import model_names
# to support pretrainedmodels.__dict__['nasnetalarge']
# but depreciated
from .models.fbresnet import fbresnet152
fro... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pretrained-models.pytorch", "path": "pretrainedmodels/__init__.py", "license": "bsd-3-clause", "size": 2210} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.