From 71022f8ccc31010037a7be08118542beb644648e Mon Sep 17 00:00:00 2001 From: Kybxd <627940450@qq.com> Date: Wed, 13 May 2026 18:01:49 +0800 Subject: [PATCH 1/4] refactor(protoc): migrate to protocompile experimental compiler The experimental compiler only accepts source files via source.Opener, so vendor required .proto deps under internal/x/xproto/protoc/embedded/ and expose them through go:embed: - tableau/protobuf/*.proto: copied from proto/tableau/protobuf/ - buf/validate/validate.proto: exported from buf.build/bufbuild/protovalidate at the commit pinned in buf.lock gen_embedded.sh (invoked via go:generate) refreshes the embedded tree and explicitly forwards buf.lock's protovalidate commit to `buf export`, since ad-hoc `buf export` does not consult buf.lock. The embedded/ tree is committed so `go install ...@latest` works without buf or go generate. --- go.mod | 12 +- go.sum | 24 +- internal/x/xproto/protoc/compiler.go | 270 +- internal/x/xproto/protoc/embed.go | 53 + .../embedded/buf/validate/validate.proto | 5057 +++++++++++++++++ .../embedded/tableau/protobuf/tableau.proto | 450 ++ .../embedded/tableau/protobuf/wellknown.proto | 115 + internal/x/xproto/protoc/gen_embedded.sh | 38 + 8 files changed, 5942 insertions(+), 77 deletions(-) create mode 100644 internal/x/xproto/protoc/embed.go create mode 100644 internal/x/xproto/protoc/embedded/buf/validate/validate.proto create mode 100644 internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto create mode 100644 internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto create mode 100755 internal/x/xproto/protoc/gen_embedded.sh diff --git a/go.mod b/go.mod index 014dbf9b..bcc2b2d2 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,11 @@ module github.com/tableauio/tableau -go 1.24.0 +go 1.25.6 require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260415201107-50325440f8f2.1 buf.build/go/protovalidate v1.2.0 - github.com/bufbuild/protocompile v0.14.1 + github.com/bufbuild/protocompile v0.14.2-0.20260429155904-12ef1ef2ce91 github.com/emirpasic/gods v1.18.1 github.com/protocolbuffers/txtpbfmt v0.0.0-20240820135758-21b1d9897dc7 github.com/rogpeppe/go-internal v1.10.0 @@ -15,7 +15,7 @@ require ( github.com/valyala/fastjson v1.6.10 github.com/xuri/excelize/v2 v2.10.1 go.uber.org/zap v1.28.0 - golang.org/x/sync v0.19.0 + golang.org/x/sync v0.20.0 golang.org/x/text v0.34.0 google.golang.org/protobuf v1.36.11 gopkg.in/natefinch/lumberjack.v2 v2.2.1 @@ -23,6 +23,7 @@ require ( ) require ( + buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.11-20250109164928-1da0de137947.1 // indirect cel.dev/expr v0.25.1 // indirect github.com/antchfx/xpath v1.3.6 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect @@ -30,16 +31,19 @@ require ( github.com/google/cel-go v0.28.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/petermattis/goid v0.0.0-20250319124200-ccd6737f222a // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/richardlehane/mscfb v1.0.6 // indirect github.com/richardlehane/msoleps v1.0.6 // indirect + github.com/rivo/uniseg v0.4.7 // indirect github.com/spf13/pflag v1.0.9 // indirect + github.com/tidwall/btree v1.8.1 // indirect github.com/tiendc/go-deepcopy v1.7.2 // indirect github.com/xuri/efp v0.0.1 // indirect github.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/crypto v0.48.0 // indirect - golang.org/x/exp v0.0.0-20250813145105-42675adae3e6 // indirect + golang.org/x/exp v0.0.0-20250911091902-df9299821621 // indirect golang.org/x/net v0.50.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250811230008-5f3141c8851a // indirect diff --git a/go.sum b/go.sum index ef84c49a..32fa82ef 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.11-20250109164928-1da0de137947.1 h1:HwzzCRS4ZrEm1++rzSDxHnO0DOjiT1b8I/24e8a4exY= +buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.11-20250109164928-1da0de137947.1/go.mod h1:8PRKXhgNes29Tjrnv8KdZzg3I1QceOkzibW1QK7EXv0= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260415201107-50325440f8f2.1 h1:s6hzCXtND/ICdGPTMGk7C+/BFlr2Jg5GyH0NKf4XGXg= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260415201107-50325440f8f2.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM= buf.build/go/protovalidate v1.2.0 h1:DQVrUWkmGTBij+kOYv/x2LLxwcLaGKMdzShj1/6/3H0= @@ -9,10 +11,12 @@ github.com/antchfx/xpath v1.3.6 h1:s0y+ElRRtTQdfHP609qFu0+c6bglDv20pqOViQjjdPI= github.com/antchfx/xpath v1.3.6/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= +github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs= +github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4= github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs= -github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw= -github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c= +github.com/bufbuild/protocompile v0.14.2-0.20260429155904-12ef1ef2ce91 h1:RPIMBLTMx/CRy0NVyb6yJDlGx2Vo84FsU+kAh46zqIA= +github.com/bufbuild/protocompile v0.14.2-0.20260429155904-12ef1ef2ce91/go.mod h1:DhgqsRznX/F0sGkUYtTQJRP+q8xMReQRQ3qr+n1opWU= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -32,14 +36,20 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/petermattis/goid v0.0.0-20250319124200-ccd6737f222a h1:S+AGcmAESQ0pXCUNnRH7V+bOUIgkSX5qVt2cNKCrm0Q= +github.com/petermattis/goid v0.0.0-20250319124200-ccd6737f222a/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/protocolbuffers/protoscope v0.0.0-20221109213918-8e7a6aafa2c9 h1:arwj11zP0yJIxIRiDn22E0H8PxfF7TsTrc2wIPFIsf4= +github.com/protocolbuffers/protoscope v0.0.0-20221109213918-8e7a6aafa2c9/go.mod h1:SKZx6stCn03JN3BOWTwvVIO2ajMkb/zQdTceXYhKw/4= github.com/protocolbuffers/txtpbfmt v0.0.0-20240820135758-21b1d9897dc7 h1:GkKZUEPNgwIk3LK4Er5vxnaNKk1pdjI3Oc6oTBwBsxQ= github.com/protocolbuffers/txtpbfmt v0.0.0-20240820135758-21b1d9897dc7/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c= github.com/richardlehane/mscfb v1.0.6 h1:eN3bvvZCp00bs7Zf52bxNwAx5lJDBK1tCuH19qq5aC8= github.com/richardlehane/mscfb v1.0.6/go.mod h1:pe0+IUIc0AHh0+teNzBlJCtSyZdFOGgV4ZK9bsoV+Jo= github.com/richardlehane/msoleps v1.0.6 h1:9BvkpjvD+iUBalUY4esMwv6uBkfOip/Lzvd93jvR9gg= github.com/richardlehane/msoleps v1.0.6/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rodaine/protogofakeit v0.1.1 h1:ZKouljuRM3A+TArppfBqnH8tGZHOwM/pjvtXe9DaXH8= github.com/rodaine/protogofakeit v0.1.1/go.mod h1:pXn/AstBYMaSfc1/RqH3N82pBuxtWgejz1AlYpY1mI0= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= @@ -53,6 +63,8 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/subchen/go-xmldom v1.1.2 h1:7evI2YqfYYOnuj+PBwyaOZZYjl3iWq35P6KfBUw9jeU= github.com/subchen/go-xmldom v1.1.2/go.mod h1:6Pg/HuX5/T4Jlj0IPJF1sRxKVoI/rrKP6LIMge9d5/8= +github.com/tidwall/btree v1.8.1 h1:27ehoXvm5AG/g+1VxLS1SD3vRhp/H7LuEfwNvddEdmA= +github.com/tidwall/btree v1.8.1/go.mod h1:jBbTdUWhSZClZWoDg54VnvV7/54modSOzDN7VXftj1A= github.com/tiendc/go-deepcopy v1.7.2 h1:Ut2yYR7W9tWjTQitganoIue4UGxZwCcJy3orjrrIj44= github.com/tiendc/go-deepcopy v1.7.2/go.mod h1:4bKjNC2r7boYOkD2IOuZpYjmlDdzjbpTRyCx+goBCJQ= github.com/valyala/fastjson v1.6.10 h1:/yjJg8jaVQdYR3arGxPE2X5z89xrlhS0eGXdv+ADTh4= @@ -73,14 +85,14 @@ go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts= golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos= -golang.org/x/exp v0.0.0-20250813145105-42675adae3e6 h1:SbTAbRFnd5kjQXbczszQ0hdk3ctwYf3qBNH9jIsGclE= -golang.org/x/exp v0.0.0-20250813145105-42675adae3e6/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4= +golang.org/x/exp v0.0.0-20250911091902-df9299821621 h1:2id6c1/gto0kaHYyrixvknJ8tUK/Qs5IsmBtrc+FtgU= +golang.org/x/exp v0.0.0-20250911091902-df9299821621/go.mod h1:TwQYMMnGpvZyc+JpB/UAuTNIsVJifOlSkrZkhcvpVUk= golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ= golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs= golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60= golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM= -golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= -golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= +golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= google.golang.org/genproto/googleapis/api v0.0.0-20250811230008-5f3141c8851a h1:DMCgtIAIQGZqJXMVzJF4MV8BlWoJh2ZuFiRdAleyr58= diff --git a/internal/x/xproto/protoc/compiler.go b/internal/x/xproto/protoc/compiler.go index c2547991..30dc9d15 100644 --- a/internal/x/xproto/protoc/compiler.go +++ b/internal/x/xproto/protoc/compiler.go @@ -1,15 +1,37 @@ +// Package protoc compiles .proto sources into a [protoregistry.Files]. +// +// It is built on top of bufbuild/protocompile's experimental incremental +// compiler, which is the only backend that supports Protobuf Edition 2024. +// The stable [github.com/bufbuild/protocompile.Compiler] was bypassed in +// favor of the experimental pipeline because: +// +// - Edition 2024 features are implemented exclusively on the experimental +// side (the stable compiler caps its MaxSupportedEdition at 2023). +// - buf v1.69+ has fully migrated to the experimental compiler. +// +// The experimental compiler only accepts .proto source files (via +// [source.Opener]); it cannot consume pre-compiled descriptors from +// [protoregistry.GlobalFiles]. To preserve the previous behaviour where +// the well-known imports of tableau and protovalidate are resolvable +// without the user supplying them explicitly, this package embeds those +// .proto sources via [embed.FS]. See [embed.go]. package protoc import ( "context" - "io" + "fmt" "io/fs" + "maps" "os" "path/filepath" + "slices" + "strings" - "github.com/bufbuild/protocompile" - "github.com/bufbuild/protocompile/linker" - "github.com/bufbuild/protocompile/protoutil" + "github.com/bufbuild/protocompile/experimental/incremental" + "github.com/bufbuild/protocompile/experimental/incremental/queries" + "github.com/bufbuild/protocompile/experimental/ir" + "github.com/bufbuild/protocompile/experimental/report" + "github.com/bufbuild/protocompile/experimental/source" "github.com/bufbuild/protocompile/walk" "github.com/tableauio/tableau/internal/x/xerrors" "github.com/tableauio/tableau/internal/x/xfs" @@ -19,14 +41,11 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" "google.golang.org/protobuf/types/descriptorpb" - - _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" - _ "github.com/tableauio/tableau/proto/tableaupb" ) -type fileDescriptorProtoMap map[string]*descriptorpb.FileDescriptorProto // file path -> file desc proto - -// NewFiles creates a new protoregistry.Files from the provided proto paths, files, and excluded proto files. +// NewFiles creates a new [protoregistry.Files] from the provided proto +// import paths, proto files (globs accepted), and excluded proto files +// (globs accepted). func NewFiles(protoPaths []string, protoFiles []string, excludedProtoFiles ...string) (*protoregistry.Files, error) { cleanSlashProtoPaths := make([]string, len(protoPaths)) for i, protoPath := range protoPaths { @@ -57,7 +76,7 @@ func NewFiles(protoPaths []string, protoFiles []string, excludedProtoFiles ...st } } } - return parseProtos(protoPaths, parsedProtoFiles) + return parseProtos(cleanSlashProtoPaths, parsedProtoFiles) } func rel(filename string, protoPaths []string) string { @@ -69,82 +88,198 @@ func rel(filename string, protoPaths []string) string { return filename } -// parseProtos parses the proto paths and proto files to protoregistry.Files. +// parseProtos parses the proto paths and proto files to protoregistry.Files +// using protocompile's experimental incremental compiler. func parseProtos(protoPaths []string, protoFilesMap map[string]string) (*protoregistry.Files, error) { log.Debugf("proto paths: %v", protoPaths) log.Debugf("proto files: %v", protoFilesMap) - var protoFiles []string - for _, path := range protoFilesMap { - protoFiles = append(protoFiles, path) - } - compiler := protocompile.Compiler{ - Resolver: protocompile.CompositeResolver{ - protocompile.ResolverFunc(resolveGlobalFiles), - &protocompile.SourceResolver{ - ImportPaths: protoPaths, - Accessor: func(path string) (io.ReadCloser, error) { - if _, ok := protoFilesMap[xfs.CleanSlashPath(path)]; !ok { - return nil, fs.ErrNotExist - } - return os.Open(path) - }, - }, - }, - MaxParallelism: 1, - } - results, err := compiler.Compile(context.Background(), protoFiles...) + + protoFiles := slices.Collect(maps.Values(protoFilesMap)) + + // Build a layered Opener: + // 1. user sources (resolved against protoPaths, gated by protoFilesMap) + // 2. embedded sources (tableau + buf/validate) + // 3. WKTs (google/protobuf/*) + userOpener := &filesystemOpener{importPaths: protoPaths} + embeddedOpener := &fsOpener{fs: embeddedFS(), tag: ""} + combined := &source.Openers{userOpener, embeddedOpener, source.WKTs()} + + workspace := source.NewWorkspace(protoFiles...) + executor := incremental.New(incremental.WithParallelism(1)) + session := new(ir.Session) + + query := queries.FDS{ + Opener: combined, + Session: session, + Workspace: workspace, + } + results, rpt, err := incremental.Run(context.Background(), executor, query) if err != nil { return nil, err } - return protodesc.NewFiles(toFDS(results)) + if err := reportToError(rpt); err != nil { + return nil, err + } + if len(results) == 0 { + return nil, fmt.Errorf("protocompile: no result returned") + } + if results[0].Fatal != nil { + return nil, results[0].Fatal + } + fds := results[0].Value + if fds == nil { + return nil, fmt.Errorf("protocompile: nil FileDescriptorSet") + } + + // The experimental compiler emits custom options as unknown wire bytes + // (it has no notion of Go-side extension types, unlike the stable + // Compiler which used [protoregistry.GlobalFiles] to drive linking). + // Re-parse each FileDescriptorProto using [protoregistry.GlobalTypes] + // as the extension resolver so that statically-known extensions + // (e.g. tableau.workbook, buf.validate.field, ...) become typed + // fields rather than opaque unknown bytes. Then strip any leftover + // dynamic extensions, mirroring the previous stable-Compiler flow. + if err := resolveTypedExtensions(fds); err != nil { + return nil, err + } + for _, fdp := range fds.GetFile() { + removeDynamicExtensionsFromProto(fdp) + } + return protodesc.NewFiles(fds) } -func resolveGlobalFiles(path string) (protocompile.SearchResult, error) { - fd, err := protoregistry.GlobalFiles.FindFileByPath(path) +// resolveTypedExtensions rewrites each FileDescriptorProto in fds so that +// any custom options that arrived as unknown wire bytes are re-decoded +// using the linked-in extension registry ([protoregistry.GlobalTypes]). +// +// This is the bridge between protocompile/experimental's +// "extension-agnostic" output and the rest of tableau, which relies on +// [proto.GetExtension] of typed extensions. +func resolveTypedExtensions(fds *descriptorpb.FileDescriptorSet) error { + resolver := protoregistry.GlobalTypes + for i, fdp := range fds.GetFile() { + data, err := proto.Marshal(fdp) + if err != nil { + return xerrors.Wrapf(err, "marshal FileDescriptorProto %q", fdp.GetName()) + } + clone := &descriptorpb.FileDescriptorProto{} + if err := (proto.UnmarshalOptions{Resolver: resolver, AllowPartial: true}).Unmarshal(data, clone); err != nil { + return xerrors.Wrapf(err, "re-unmarshal FileDescriptorProto %q with extension resolver", fdp.GetName()) + } + fds.File[i] = clone + } + return nil +} + +// filesystemOpener resolves a proto path against a list of import roots, +// matching the semantics of the stable [protocompile.SourceResolver]: +// +// - When importPaths is non-empty, the requested path is treated as +// relative to one of the roots; the verbatim path is NOT tried. +// - When importPaths is empty, the path is opened verbatim relative to +// the current working directory. +// +// Opener implementations are required by protocompile to be comparable; +// we use a pointer receiver so identity equality holds across query reuse. +type filesystemOpener struct { + importPaths []string +} + +// Open implements [source.Opener]. +func (o *filesystemOpener) Open(path string) (*source.File, error) { + clean := xfs.CleanSlashPath(path) + if len(o.importPaths) == 0 { + if data, err := os.ReadFile(clean); err == nil { + return source.NewFile(path, string(data)), nil + } + return nil, fs.ErrNotExist + } + for _, root := range o.importPaths { + full := xfs.CleanSlashPath(filepath.Join(root, clean)) + if data, err := os.ReadFile(full); err == nil { + return source.NewFile(path, string(data)), nil + } + } + return nil, fs.ErrNotExist +} + +// fsOpener adapts an [fs.FS] (e.g. an embed.FS) to [source.Opener]. +// +// Like [filesystemOpener], it must be comparable; we use a pointer receiver +// and only pointer-compare the wrapped fs.FS handle for query caching. +type fsOpener struct { + fs fs.FS + tag string // used as the prefix of File.Path() for diagnostics +} + +// Open implements [source.Opener]. +func (o *fsOpener) Open(path string) (*source.File, error) { + clean := strings.TrimPrefix(xfs.CleanSlashPath(path), "./") + data, err := fs.ReadFile(o.fs, clean) if err != nil { - return protocompile.SearchResult{}, err + return nil, err } - return protocompile.SearchResult{Desc: fd}, nil + return source.NewFile(o.tag+"/"+path, string(data)), nil } -// toFDS converts linker.Files to *descriptorpb.FileDescriptorSet. -func toFDS(results linker.Files) *descriptorpb.FileDescriptorSet { - fdpMap := make(fileDescriptorProtoMap) - for _, res := range results { - convertFile(res, fdpMap) +// reportToError converts protocompile diagnostics into a single error if +// any diagnostic at Error level or above was emitted. Warnings are logged +// but not treated as failures. +// +// Each diagnostic is formatted to match buf's convention: +// +// ::: +// +// When no source span is available, the line/column components are +// omitted. When no file is available, only the message is emitted. +func reportToError(rpt *report.Report) error { + if rpt == nil { + return nil } - fdps := make([]*descriptorpb.FileDescriptorProto, 0, len(fdpMap)) - for _, fdp := range fdpMap { - fdps = append(fdps, fdp) + var errs []string + for i := range rpt.Diagnostics { + d := &rpt.Diagnostics[i] + msg := formatDiagnostic(d) + switch d.Level() { + case report.Error, report.ICE: + errs = append(errs, msg) + case report.Warning: + log.Warnf("protocompile: %s", msg) + } } - return &descriptorpb.FileDescriptorSet{File: fdps} + if len(errs) == 0 { + return nil + } + return fmt.Errorf("protocompile: %s", strings.Join(errs, "\n")) } -func convertFile(d protoreflect.FileDescriptor, fdpMap fileDescriptorProtoMap) { - if _, ok := fdpMap[d.Path()]; ok { - // skip duplicate conversion - return +// formatDiagnostic renders a single diagnostic in buf's +// ":::" format. Missing components are skipped. +func formatDiagnostic(d *report.Diagnostic) string { + file := d.File() + span := d.Primary() + if !span.IsZero() { + loc := span.StartLoc() + if file != "" { + return fmt.Sprintf("%s:%d:%d:%s", file, loc.Line, loc.Column, d.Message()) + } + return fmt.Sprintf("%d:%d:%s", loc.Line, loc.Column, d.Message()) } - fdp := protoutil.ProtoFromFileDescriptor(d) - removeDynamicExtensionsFromProto(fdp) - fdpMap[d.Path()] = fdp - // convert imports recursively - imports := d.Imports() - for i := 0; i < imports.Len(); i++ { - convertFile(imports.Get(i).FileDescriptor, fdpMap) + if file != "" { + return fmt.Sprintf("%s:%s", file, d.Message()) } + return d.Message() } +// removeDynamicExtensionsFromProto rewrites *FileDescriptorProto-tree +// options so that custom options known to the linked-in Go runtime +// surface as concrete generated types (e.g. *tableaupb.UnionOptions) +// instead of dynamicpb messages. +// +// Refer: +// +// https://github.com/jhump/protoreflect/blob/v1.17.0/desc/protoparse/parser.go#L724 func removeDynamicExtensionsFromProto(fd *descriptorpb.FileDescriptorProto) { - // protocompile returns descriptors with dynamic extension fields for custom options. - // But tableau only uses known custom options (*tableaupb.UnionOptions rather than - // *dynamicpb.Message for example). So to bridge the difference in behavior, we need - // to remove custom options from the given file and add them back via - // serializing-then-de-serializing them back into the options messages. That way, - // statically known options will be properly typed and others will be unrecognized. - // - // Refer: - // https://github.com/jhump/protoreflect/blob/v1.17.0/desc/protoparse/parser.go#L724 fd.Options = removeDynamicExtensionsFromOptions(fd.Options) err := walk.DescriptorProtos(fd, func(_ protoreflect.FullName, msg proto.Message) error { switch msg := msg.(type) { @@ -194,7 +329,8 @@ func removeOne(opts protoreflect.Message) { log.Warnf("marshal dynamic options failed: %v", err) return } - // and then replace values by clearing these custom options and deserializing + // and then replace values by clearing these custom options and + // deserializing. err = proto.UnmarshalOptions{AllowPartial: true, Merge: true}.Unmarshal(data, opts.Interface()) if err != nil { // oh, well... can't fix this one diff --git a/internal/x/xproto/protoc/embed.go b/internal/x/xproto/protoc/embed.go new file mode 100644 index 00000000..aac20b85 --- /dev/null +++ b/internal/x/xproto/protoc/embed.go @@ -0,0 +1,53 @@ +package protoc + +import ( + "embed" + "io/fs" +) + +// Embedded .proto sources used as fallback dependencies for protocompile's +// experimental compiler. The experimental compiler only accepts source files +// (via [source.Opener]) and does not support injecting pre-compiled +// FileDescriptors via protoreglistry.GlobalFiles like the stable Compiler did. +// +// We embed: +// - tableau/protobuf/*.proto (this repository's own schemas, copied from +// proto/tableau/protobuf/) +// - buf/validate/*.proto (the protovalidate schemas, exported from the buf +// module pinned in buf.lock) +// +// Standard imports (google/protobuf/*) are provided automatically by +// [source.WKTs]. +// +// The contents under embedded/ ARE checked into version control so that +// downstream consumers (e.g. `go install github.com/tableauio/tableau/cmd/ +// tableauc@latest`) can build without running `go generate` or having `buf` +// installed. Run `go generate ./...` after editing proto/tableau/protobuf/ +// or bumping the protovalidate dep in buf.lock to refresh embedded/. +// +// Version pinning: `buf export ` does NOT consult the +// workspace's buf.lock — that file only governs transitive resolution for +// modules declared inside the workspace. Without an explicit commit suffix, +// `buf export` always pulls the latest published commit. To stay aligned +// with buf.lock (the single source of truth for the protovalidate version), +// gen_embedded.sh reads the commit out of buf.lock at generate time and +// passes it to `buf export`. To upgrade, run `buf dep update` then +// `go generate ./...`. + +//go:generate ./gen_embedded.sh + +//go:embed embedded/buf/validate/validate.proto +//go:embed embedded/tableau/protobuf/tableau.proto +//go:embed embedded/tableau/protobuf/wellknown.proto +var embeddedProtos embed.FS + +// embeddedFS returns the embedded.FS rooted at "embedded/" so that paths +// look like "buf/validate/validate.proto" or "tableau/protobuf/tableau.proto". +func embeddedFS() fs.FS { + sub, err := fs.Sub(embeddedProtos, "embedded") + if err != nil { + // Should never happen because the directory is hard-coded. + panic(err) + } + return sub +} diff --git a/internal/x/xproto/protoc/embedded/buf/validate/validate.proto b/internal/x/xproto/protoc/embedded/buf/validate/validate.proto new file mode 100644 index 00000000..f0371d39 --- /dev/null +++ b/internal/x/xproto/protoc/embedded/buf/validate/validate.proto @@ -0,0 +1,5057 @@ +// Copyright 2023-2026 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto2"; + +// [Protovalidate](https://protovalidate.com/) is the semantic validation library for Protobuf. +// It provides standard annotations to validate common rules on messages and fields, as well as the ability to use [CEL](https://cel.dev) to write custom rules. +// It's the next generation of [protoc-gen-validate](https://github.com/bufbuild/protoc-gen-validate). +// +// This package provides the options, messages, and enums that power Protovalidate. +// Apply its options to messages, fields, and oneofs in your Protobuf schemas to add validation rules: +// +// ```proto +// message User { +// string id = 1 [(buf.validate.field).string.uuid = true]; +// string first_name = 2 [(buf.validate.field).string.max_len = 64]; +// string last_name = 3 [(buf.validate.field).string.max_len = 64]; +// +// option (buf.validate.message).cel = { +// id: "first_name_requires_last_name" +// message: "last_name must be present if first_name is present" +// expression: "!has(this.first_name) || has(this.last_name)" +// }; +// } +// ``` +// +// These rules are enforced at runtime by language-specific libraries. +// See the [developer quickstart](https://protovalidate.com/quickstart/) to get started, or go directly to the runtime library for your language: +// [Go](https://github.com/bufbuild/protovalidate-go) +// [JavaScript/TypeScript](https://github.com/bufbuild/protovalidate-es), +// [Java](https://github.com/bufbuild/protovalidate-java), +// [Python](https://github.com/bufbuild/protovalidate-python), +// or [C++](https://github.com/bufbuild/protovalidate-cc). +package buf.validate; + +import "google/protobuf/descriptor.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"; +option java_multiple_files = true; +option java_outer_classname = "ValidateProto"; +option java_package = "build.buf.validate"; + +// MessageOptions is an extension to google.protobuf.MessageOptions. It allows +// the addition of validation rules at the message level. These rules can be +// applied to incoming messages to ensure they meet certain criteria before +// being processed. +extend google.protobuf.MessageOptions { + // Rules specify the validations to be performed on this message. By default, + // no validation is performed against a message. + optional MessageRules message = 1159; +} + +// OneofOptions is an extension to google.protobuf.OneofOptions. It allows +// the addition of validation rules on a oneof. These rules can be +// applied to incoming messages to ensure they meet certain criteria before +// being processed. +extend google.protobuf.OneofOptions { + // Rules specify the validations to be performed on this oneof. By default, + // no validation is performed against a oneof. + optional OneofRules oneof = 1159; +} + +// FieldOptions is an extension to google.protobuf.FieldOptions. It allows +// the addition of validation rules at the field level. These rules can be +// applied to incoming messages to ensure they meet certain criteria before +// being processed. +extend google.protobuf.FieldOptions { + // Rules specify the validations to be performed on this field. By default, + // no validation is performed against a field. + optional FieldRules field = 1159; + + // Specifies predefined rules. When extending a standard rule message, + // this adds additional CEL expressions that apply when the extension is used. + // + // ```proto + // extend buf.validate.Int32Rules { + // bool is_zero [(buf.validate.predefined).cel = { + // id: "int32.is_zero", + // message: "value must be zero", + // expression: "!rule || this == 0", + // }]; + // } + // + // message Foo { + // int32 reserved = 1 [(buf.validate.field).int32.(is_zero) = true]; + // } + // ``` + optional PredefinedRules predefined = 1160; +} + +// `Rule` represents a validation rule written in the Common Expression +// Language (CEL) syntax. Each Rule includes a unique identifier, an +// optional error message, and the CEL expression to evaluate. For more +// information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). +// +// ```proto +// message Foo { +// option (buf.validate.message).cel = { +// id: "foo.bar" +// message: "bar must be greater than 0" +// expression: "this.bar > 0" +// }; +// int32 bar = 1; +// } +// ``` +message Rule { + // `id` is a string that serves as a machine-readable name for this Rule. + // It should be unique within its scope, which could be either a message or a field. + optional string id = 1; + + // `message` is an optional field that provides a human-readable error message + // for this Rule when the CEL expression evaluates to false. If a + // non-empty message is provided, any strings resulting from the CEL + // expression evaluation are ignored. + optional string message = 2; + + // `expression` is the actual CEL expression that will be evaluated for + // validation. This string must resolve to either a boolean or a string + // value. If the expression evaluates to false or a non-empty string, the + // validation is considered failed, and the message is rejected. + optional string expression = 3; +} + +// MessageRules represents validation rules that are applied to the entire message. +// It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules. +message MessageRules { + // `cel_expression` is a repeated field CEL expressions. Each expression specifies a validation + // rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax. + // + // This is a simplified form of the `cel` Rule field, where only `expression` is set. This allows for + // simpler syntax when defining CEL Rules where `id` and `message` derived from the `expression`. `id` will + // be same as the `expression`. + // + // For more information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). + // + // ```proto + // message MyMessage { + // // The field `foo` must be greater than 42. + // option (buf.validate.message).cel_expression = "this.foo > 42"; + // // The field `foo` must be less than 84. + // option (buf.validate.message).cel_expression = "this.foo < 84"; + // optional int32 foo = 1; + // } + // ``` + repeated string cel_expression = 5; + // `cel` is a repeated field of type Rule. Each Rule specifies a validation rule to be applied to this message. + // These rules are written in Common Expression Language (CEL) syntax. For more information, + // [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). + // + // + // ```proto + // message MyMessage { + // // The field `foo` must be greater than 42. + // option (buf.validate.message).cel = { + // id: "my_message.value", + // message: "value must be greater than 42", + // expression: "this.foo > 42", + // }; + // optional int32 foo = 1; + // } + // ``` + repeated Rule cel = 3; + + // `oneof` is a repeated field of type MessageOneofRule that specifies a list of fields + // of which at most one can be present. If `required` is also specified, then exactly one + // of the specified fields _must_ be present. + // + // This will enforce oneof-like constraints with a few features not provided by + // actual Protobuf oneof declarations: + // 1. Repeated and map fields are allowed in this validation. In a Protobuf oneof, + // only scalar fields are allowed. + // 2. Fields with implicit presence are allowed. In a Protobuf oneof, all member + // fields have explicit presence. This means that, for the purpose of determining + // how many fields are set, explicitly setting such a field to its zero value is + // effectively the same as not setting it at all. + // 3. This will always generate validation errors for a message unmarshalled from + // serialized data that sets more than one field. With a Protobuf oneof, when + // multiple fields are present in the serialized form, earlier values are usually + // silently ignored when unmarshalling, with only the last field being set when + // unmarshalling completes. + // + // Note that adding a field to a `oneof` will also set the IGNORE_IF_ZERO_VALUE on the fields. This means + // only the field that is set will be validated and the unset fields are not validated according to the field rules. + // This behavior can be overridden by setting `ignore` against a field. + // + // ```proto + // message MyMessage { + // // Only one of `field1` or `field2` _can_ be present in this message. + // option (buf.validate.message).oneof = { fields: ["field1", "field2"] }; + // // Exactly one of `field3` or `field4` _must_ be present in this message. + // option (buf.validate.message).oneof = { fields: ["field3", "field4"], required: true }; + // string field1 = 1; + // bytes field2 = 2; + // bool field3 = 3; + // int32 field4 = 4; + // } + // ``` + repeated MessageOneofRule oneof = 4; + + reserved 1; + reserved "disabled"; +} + +message MessageOneofRule { + // A list of field names to include in the oneof. All field names must be + // defined in the message. At least one field must be specified, and + // duplicates are not permitted. + repeated string fields = 1; + // If true, one of the fields specified _must_ be set. + optional bool required = 2; +} + +// The `OneofRules` message type enables you to manage rules for +// oneof fields in your protobuf messages. +message OneofRules { + // If `required` is true, exactly one field of the oneof must be set. A + // validation error is returned if no fields in the oneof are set. Further rules + // should be placed on the fields themselves to ensure they are valid values, + // such as `min_len` or `gt`. + // + // ```proto + // message MyMessage { + // oneof value { + // // Either `a` or `b` must be set. If `a` is set, it must also be + // // non-empty; whereas if `b` is set, it can still be an empty string. + // option (buf.validate.oneof).required = true; + // string a = 1 [(buf.validate.field).string.min_len = 1]; + // string b = 2; + // } + // } + // ``` + optional bool required = 1; +} + +// FieldRules encapsulates the rules for each type of field. Depending on +// the field, the correct set should be used to ensure proper validations. +message FieldRules { + // `cel_expression` is a repeated field CEL expressions. Each expression specifies a validation + // rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax. + // + // This is a simplified form of the `cel` Rule field, where only `expression` is set. This allows for + // simpler syntax when defining CEL Rules where `id` and `message` derived from the `expression`. `id` will + // be same as the `expression`. + // + // For more information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). + // + // ```proto + // message MyMessage { + // // The field `value` must be greater than 42. + // optional int32 value = 1 [(buf.validate.field).cel_expression = "this > 42"]; + // } + // ``` + repeated string cel_expression = 29; + // `cel` is a repeated field used to represent a textual expression + // in the Common Expression Language (CEL) syntax. For more information, + // [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). + // + // ```proto + // message MyMessage { + // // The field `value` must be greater than 42. + // optional int32 value = 1 [(buf.validate.field).cel = { + // id: "my_message.value", + // message: "value must be greater than 42", + // expression: "this > 42", + // }]; + // } + // ``` + repeated Rule cel = 23; + // If `required` is true, the field must be set. A validation error is returned + // if the field is not set. + // + // ```proto + // syntax="proto3"; + // + // message FieldsWithPresence { + // // Requires any string to be set, including the empty string. + // optional string link = 1 [ + // (buf.validate.field).required = true + // ]; + // // Requires true or false to be set. + // optional bool disabled = 2 [ + // (buf.validate.field).required = true + // ]; + // // Requires a message to be set, including the empty message. + // SomeMessage msg = 4 [ + // (buf.validate.field).required = true + // ]; + // } + // ``` + // + // All fields in the example above track presence. By default, Protovalidate + // ignores rules on those fields if no value is set. `required` ensures that + // the fields are set and valid. + // + // Fields that don't track presence are always validated by Protovalidate, + // whether they are set or not. It is not necessary to add `required`. It + // can be added to indicate that the field cannot be the zero value. + // + // ```proto + // syntax="proto3"; + // + // message FieldsWithoutPresence { + // // `string.email` always applies, even to an empty string. + // string link = 1 [ + // (buf.validate.field).string.email = true + // ]; + // // `repeated.min_items` always applies, even to an empty list. + // repeated string labels = 2 [ + // (buf.validate.field).repeated.min_items = 1 + // ]; + // // `required`, for fields that don't track presence, indicates + // // the value of the field can't be the zero value. + // int32 zero_value_not_allowed = 3 [ + // (buf.validate.field).required = true + // ]; + // } + // ``` + // + // To learn which fields track presence, see the + // [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat). + // + // Note: While field rules can be applied to repeated items, map keys, and map + // values, the elements are always considered to be set. Consequently, + // specifying `repeated.items.required` is redundant. + optional bool required = 25; + // Ignore validation rules on the field if its value matches the specified + // criteria. See the `Ignore` enum for details. + // + // ```proto + // message UpdateRequest { + // // The uri rule only applies if the field is not an empty string. + // string url = 1 [ + // (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + // (buf.validate.field).string.uri = true + // ]; + // } + // ``` + optional Ignore ignore = 27; + + oneof type { + // Scalar Field Types + FloatRules float = 1; + DoubleRules double = 2; + Int32Rules int32 = 3; + Int64Rules int64 = 4; + UInt32Rules uint32 = 5; + UInt64Rules uint64 = 6; + SInt32Rules sint32 = 7; + SInt64Rules sint64 = 8; + Fixed32Rules fixed32 = 9; + Fixed64Rules fixed64 = 10; + SFixed32Rules sfixed32 = 11; + SFixed64Rules sfixed64 = 12; + BoolRules bool = 13; + StringRules string = 14; + BytesRules bytes = 15; + + // Complex Field Types + EnumRules enum = 16; + RepeatedRules repeated = 18; + MapRules map = 19; + + // Well-Known Field Types + AnyRules any = 20; + DurationRules duration = 21; + FieldMaskRules field_mask = 28; + TimestampRules timestamp = 22; + } + + reserved 24, 26; + reserved "skipped", "ignore_empty"; +} + +// PredefinedRules are custom rules that can be re-used with +// multiple fields. +message PredefinedRules { + // `cel` is a repeated field used to represent a textual expression + // in the Common Expression Language (CEL) syntax. For more information, + // [see our documentation](https://buf.build/docs/protovalidate/schemas/predefined-rules/). + // + // ```proto + // message MyMessage { + // // The field `value` must be greater than 42. + // optional int32 value = 1 [(buf.validate.predefined).cel = { + // id: "my_message.value", + // message: "value must be greater than 42", + // expression: "this > 42", + // }]; + // } + // ``` + repeated Rule cel = 1; + + reserved 24, 26; + reserved "skipped", "ignore_empty"; +} + +// Specifies how `FieldRules.ignore` behaves, depending on the field's value, and +// whether the field tracks presence. +enum Ignore { + // Ignore rules if the field tracks presence and is unset. This is the default + // behavior. + // + // In proto3, only message fields, members of a Protobuf `oneof`, and fields + // with the `optional` label track presence. Consequently, the following fields + // are always validated, whether a value is set or not: + // + // ```proto + // syntax="proto3"; + // + // message RulesApply { + // string email = 1 [ + // (buf.validate.field).string.email = true + // ]; + // int32 age = 2 [ + // (buf.validate.field).int32.gt = 0 + // ]; + // repeated string labels = 3 [ + // (buf.validate.field).repeated.min_items = 1 + // ]; + // } + // ``` + // + // In contrast, the following fields track presence, and are only validated if + // a value is set: + // + // ```proto + // syntax="proto3"; + // + // message RulesApplyIfSet { + // optional string email = 1 [ + // (buf.validate.field).string.email = true + // ]; + // oneof ref { + // string reference = 2 [ + // (buf.validate.field).string.uuid = true + // ]; + // string name = 3 [ + // (buf.validate.field).string.min_len = 4 + // ]; + // } + // SomeMessage msg = 4 [ + // (buf.validate.field).cel = {/* ... */} + // ]; + // } + // ``` + // + // To ensure that such a field is set, add the `required` rule. + // + // To learn which fields track presence, see the + // [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat). + IGNORE_UNSPECIFIED = 0; + + // Ignore rules if the field is unset, or set to the zero value. + // + // The zero value depends on the field type: + // - For strings, the zero value is the empty string. + // - For bytes, the zero value is empty bytes. + // - For bool, the zero value is false. + // - For numeric types, the zero value is zero. + // - For enums, the zero value is the first defined enum value. + // - For repeated fields, the zero is an empty list. + // - For map fields, the zero is an empty map. + // - For message fields, absence of the message (typically a null-value) is considered zero value. + // + // For fields that track presence (e.g. adding the `optional` label in proto3), + // this a no-op and behavior is the same as the default `IGNORE_UNSPECIFIED`. + IGNORE_IF_ZERO_VALUE = 1; + + // Always ignore rules, including the `required` rule. + // + // This is useful for ignoring the rules of a referenced message, or to + // temporarily ignore rules during development. + // + // ```proto + // message MyMessage { + // // The field's rules will always be ignored, including any validations + // // on value's fields. + // MyOtherMessage value = 1 [ + // (buf.validate.field).ignore = IGNORE_ALWAYS + // ]; + // } + // ``` + IGNORE_ALWAYS = 3; + + reserved 2; + reserved "IGNORE_EMPTY", "IGNORE_DEFAULT", "IGNORE_IF_DEFAULT_VALUE", "IGNORE_IF_UNPOPULATED"; +} + +// FloatRules describes the rules applied to `float` values. These +// rules may also be applied to the `google.protobuf.FloatValue` Well-Known-Type. +message FloatRules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyFloat { + // // value must equal 42.0 + // float value = 1 [(buf.validate.field).float.const = 42.0]; + // } + // ``` + optional float const = 1 [(predefined).cel = { + id: "float.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be less than 10.0 + // float value = 1 [(buf.validate.field).float.lt = 10.0]; + // } + // ``` + float lt = 2 [(predefined).cel = { + id: "float.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be less than or equal to 10.0 + // float value = 1 [(buf.validate.field).float.lte = 10.0]; + // } + // ``` + float lte = 3 [(predefined).cel = { + id: "float.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be greater than 5.0 [float.gt] + // float value = 1 [(buf.validate.field).float.gt = 5.0]; + // + // // value must be greater than 5 and less than 10.0 [float.gt_lt] + // float other_value = 2 [(buf.validate.field).float = { gt: 5.0, lt: 10.0 }]; + // + // // value must be greater than 10 or less than 5.0 [float.gt_lt_exclusive] + // float another_value = 3 [(buf.validate.field).float = { gt: 10.0, lt: 5.0 }]; + // } + // ``` + float gt = 4 [ + (predefined).cel = { + id: "float.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "float.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "float.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be greater than or equal to 5.0 [float.gte] + // float value = 1 [(buf.validate.field).float.gte = 5.0]; + // + // // value must be greater than or equal to 5.0 and less than 10.0 [float.gte_lt] + // float other_value = 2 [(buf.validate.field).float = { gte: 5.0, lt: 10.0 }]; + // + // // value must be greater than or equal to 10.0 or less than 5.0 [float.gte_lt_exclusive] + // float another_value = 3 [(buf.validate.field).float = { gte: 10.0, lt: 5.0 }]; + // } + // ``` + float gte = 5 [ + (predefined).cel = { + id: "float.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "float.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "float.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message + // is generated. + // + // ```proto + // message MyFloat { + // // value must be in list [1.0, 2.0, 3.0] + // float value = 1 [(buf.validate.field).float = { in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated float in = 6 [(predefined).cel = { + id: "float.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyFloat { + // // value must not be in list [1.0, 2.0, 3.0] + // float value = 1 [(buf.validate.field).float = { not_in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated float not_in = 7 [(predefined).cel = { + id: "float.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `finite` requires the field value to be finite. If the field value is + // infinite or NaN, an error message is generated. + optional bool finite = 8 [(predefined).cel = { + id: "float.finite" + expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFloat { + // float value = 1 [ + // (buf.validate.field).float.example = 1.0, + // (buf.validate.field).float.example = inf + // ]; + // } + // ``` + repeated float example = 9 [(predefined).cel = { + id: "float.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// DoubleRules describes the rules applied to `double` values. These +// rules may also be applied to the `google.protobuf.DoubleValue` Well-Known-Type. +message DoubleRules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyDouble { + // // value must equal 42.0 + // double value = 1 [(buf.validate.field).double.const = 42.0]; + // } + // ``` + optional double const = 1 [(predefined).cel = { + id: "double.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyDouble { + // // value must be less than 10.0 + // double value = 1 [(buf.validate.field).double.lt = 10.0]; + // } + // ``` + double lt = 2 [(predefined).cel = { + id: "double.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified value + // (field <= value). If the field value is greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyDouble { + // // value must be less than or equal to 10.0 + // double value = 1 [(buf.validate.field).double.lte = 10.0]; + // } + // ``` + double lte = 3 [(predefined).cel = { + id: "double.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or `lte`, + // the range is reversed, and the field value must be outside the specified + // range. If the field value doesn't meet the required conditions, an error + // message is generated. + // + // ```proto + // message MyDouble { + // // value must be greater than 5.0 [double.gt] + // double value = 1 [(buf.validate.field).double.gt = 5.0]; + // + // // value must be greater than 5 and less than 10.0 [double.gt_lt] + // double other_value = 2 [(buf.validate.field).double = { gt: 5.0, lt: 10.0 }]; + // + // // value must be greater than 10 or less than 5.0 [double.gt_lt_exclusive] + // double another_value = 3 [(buf.validate.field).double = { gt: 10.0, lt: 5.0 }]; + // } + // ``` + double gt = 4 [ + (predefined).cel = { + id: "double.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "double.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "double.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyDouble { + // // value must be greater than or equal to 5.0 [double.gte] + // double value = 1 [(buf.validate.field).double.gte = 5.0]; + // + // // value must be greater than or equal to 5.0 and less than 10.0 [double.gte_lt] + // double other_value = 2 [(buf.validate.field).double = { gte: 5.0, lt: 10.0 }]; + // + // // value must be greater than or equal to 10.0 or less than 5.0 [double.gte_lt_exclusive] + // double another_value = 3 [(buf.validate.field).double = { gte: 10.0, lt: 5.0 }]; + // } + // ``` + double gte = 5 [ + (predefined).cel = { + id: "double.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "double.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "double.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyDouble { + // // value must be in list [1.0, 2.0, 3.0] + // double value = 1 [(buf.validate.field).double = { in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated double in = 6 [(predefined).cel = { + id: "double.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyDouble { + // // value must not be in list [1.0, 2.0, 3.0] + // double value = 1 [(buf.validate.field).double = { not_in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated double not_in = 7 [(predefined).cel = { + id: "double.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `finite` requires the field value to be finite. If the field value is + // infinite or NaN, an error message is generated. + optional bool finite = 8 [(predefined).cel = { + id: "double.finite" + expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyDouble { + // double value = 1 [ + // (buf.validate.field).double.example = 1.0, + // (buf.validate.field).double.example = inf + // ]; + // } + // ``` + repeated double example = 9 [(predefined).cel = { + id: "double.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// Int32Rules describes the rules applied to `int32` values. These +// rules may also be applied to the `google.protobuf.Int32Value` Well-Known-Type. +message Int32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must equal 42 + // int32 value = 1 [(buf.validate.field).int32.const = 42]; + // } + // ``` + optional int32 const = 1 [(predefined).cel = { + id: "int32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field + // < value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be less than 10 + // int32 value = 1 [(buf.validate.field).int32.lt = 10]; + // } + // ``` + int32 lt = 2 [(predefined).cel = { + id: "int32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be less than or equal to 10 + // int32 value = 1 [(buf.validate.field).int32.lte = 10]; + // } + // ``` + int32 lte = 3 [(predefined).cel = { + id: "int32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be greater than 5 [int32.gt] + // int32 value = 1 [(buf.validate.field).int32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [int32.gt_lt] + // int32 other_value = 2 [(buf.validate.field).int32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [int32.gt_lt_exclusive] + // int32 another_value = 3 [(buf.validate.field).int32 = { gt: 10, lt: 5 }]; + // } + // ``` + int32 gt = 4 [ + (predefined).cel = { + id: "int32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified value + // (exclusive). If the value of `gte` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be greater than or equal to 5 [int32.gte] + // int32 value = 1 [(buf.validate.field).int32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [int32.gte_lt] + // int32 other_value = 2 [(buf.validate.field).int32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [int32.gte_lt_exclusive] + // int32 another_value = 3 [(buf.validate.field).int32 = { gte: 10, lt: 5 }]; + // } + // ``` + int32 gte = 5 [ + (predefined).cel = { + id: "int32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyInt32 { + // // value must be in list [1, 2, 3] + // int32 value = 1 [(buf.validate.field).int32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated int32 in = 6 [(predefined).cel = { + id: "int32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error message + // is generated. + // + // ```proto + // message MyInt32 { + // // value must not be in list [1, 2, 3] + // int32 value = 1 [(buf.validate.field).int32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated int32 not_in = 7 [(predefined).cel = { + id: "int32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyInt32 { + // int32 value = 1 [ + // (buf.validate.field).int32.example = 1, + // (buf.validate.field).int32.example = -10 + // ]; + // } + // ``` + repeated int32 example = 8 [(predefined).cel = { + id: "int32.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// Int64Rules describes the rules applied to `int64` values. These +// rules may also be applied to the `google.protobuf.Int64Value` Well-Known-Type. +message Int64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must equal 42 + // int64 value = 1 [(buf.validate.field).int64.const = 42]; + // } + // ``` + optional int64 const = 1 [(predefined).cel = { + id: "int64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be less than 10 + // int64 value = 1 [(buf.validate.field).int64.lt = 10]; + // } + // ``` + int64 lt = 2 [(predefined).cel = { + id: "int64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be less than or equal to 10 + // int64 value = 1 [(buf.validate.field).int64.lte = 10]; + // } + // ``` + int64 lte = 3 [(predefined).cel = { + id: "int64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be greater than 5 [int64.gt] + // int64 value = 1 [(buf.validate.field).int64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [int64.gt_lt] + // int64 other_value = 2 [(buf.validate.field).int64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [int64.gt_lt_exclusive] + // int64 another_value = 3 [(buf.validate.field).int64 = { gt: 10, lt: 5 }]; + // } + // ``` + int64 gt = 4 [ + (predefined).cel = { + id: "int64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be greater than or equal to 5 [int64.gte] + // int64 value = 1 [(buf.validate.field).int64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [int64.gte_lt] + // int64 other_value = 2 [(buf.validate.field).int64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [int64.gte_lt_exclusive] + // int64 another_value = 3 [(buf.validate.field).int64 = { gte: 10, lt: 5 }]; + // } + // ``` + int64 gte = 5 [ + (predefined).cel = { + id: "int64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyInt64 { + // // value must be in list [1, 2, 3] + // int64 value = 1 [(buf.validate.field).int64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated int64 in = 6 [(predefined).cel = { + id: "int64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyInt64 { + // // value must not be in list [1, 2, 3] + // int64 value = 1 [(buf.validate.field).int64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated int64 not_in = 7 [(predefined).cel = { + id: "int64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyInt64 { + // int64 value = 1 [ + // (buf.validate.field).int64.example = 1, + // (buf.validate.field).int64.example = -10 + // ]; + // } + // ``` + repeated int64 example = 9 [(predefined).cel = { + id: "int64.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// UInt32Rules describes the rules applied to `uint32` values. These +// rules may also be applied to the `google.protobuf.UInt32Value` Well-Known-Type. +message UInt32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must equal 42 + // uint32 value = 1 [(buf.validate.field).uint32.const = 42]; + // } + // ``` + optional uint32 const = 1 [(predefined).cel = { + id: "uint32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be less than 10 + // uint32 value = 1 [(buf.validate.field).uint32.lt = 10]; + // } + // ``` + uint32 lt = 2 [(predefined).cel = { + id: "uint32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be less than or equal to 10 + // uint32 value = 1 [(buf.validate.field).uint32.lte = 10]; + // } + // ``` + uint32 lte = 3 [(predefined).cel = { + id: "uint32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be greater than 5 [uint32.gt] + // uint32 value = 1 [(buf.validate.field).uint32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [uint32.gt_lt] + // uint32 other_value = 2 [(buf.validate.field).uint32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [uint32.gt_lt_exclusive] + // uint32 another_value = 3 [(buf.validate.field).uint32 = { gt: 10, lt: 5 }]; + // } + // ``` + uint32 gt = 4 [ + (predefined).cel = { + id: "uint32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be greater than or equal to 5 [uint32.gte] + // uint32 value = 1 [(buf.validate.field).uint32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [uint32.gte_lt] + // uint32 other_value = 2 [(buf.validate.field).uint32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [uint32.gte_lt_exclusive] + // uint32 another_value = 3 [(buf.validate.field).uint32 = { gte: 10, lt: 5 }]; + // } + // ``` + uint32 gte = 5 [ + (predefined).cel = { + id: "uint32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyUInt32 { + // // value must be in list [1, 2, 3] + // uint32 value = 1 [(buf.validate.field).uint32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated uint32 in = 6 [(predefined).cel = { + id: "uint32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyUInt32 { + // // value must not be in list [1, 2, 3] + // uint32 value = 1 [(buf.validate.field).uint32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated uint32 not_in = 7 [(predefined).cel = { + id: "uint32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyUInt32 { + // uint32 value = 1 [ + // (buf.validate.field).uint32.example = 1, + // (buf.validate.field).uint32.example = 10 + // ]; + // } + // ``` + repeated uint32 example = 8 [(predefined).cel = { + id: "uint32.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// UInt64Rules describes the rules applied to `uint64` values. These +// rules may also be applied to the `google.protobuf.UInt64Value` Well-Known-Type. +message UInt64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must equal 42 + // uint64 value = 1 [(buf.validate.field).uint64.const = 42]; + // } + // ``` + optional uint64 const = 1 [(predefined).cel = { + id: "uint64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be less than 10 + // uint64 value = 1 [(buf.validate.field).uint64.lt = 10]; + // } + // ``` + uint64 lt = 2 [(predefined).cel = { + id: "uint64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be less than or equal to 10 + // uint64 value = 1 [(buf.validate.field).uint64.lte = 10]; + // } + // ``` + uint64 lte = 3 [(predefined).cel = { + id: "uint64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be greater than 5 [uint64.gt] + // uint64 value = 1 [(buf.validate.field).uint64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [uint64.gt_lt] + // uint64 other_value = 2 [(buf.validate.field).uint64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [uint64.gt_lt_exclusive] + // uint64 another_value = 3 [(buf.validate.field).uint64 = { gt: 10, lt: 5 }]; + // } + // ``` + uint64 gt = 4 [ + (predefined).cel = { + id: "uint64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be greater than or equal to 5 [uint64.gte] + // uint64 value = 1 [(buf.validate.field).uint64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [uint64.gte_lt] + // uint64 other_value = 2 [(buf.validate.field).uint64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [uint64.gte_lt_exclusive] + // uint64 another_value = 3 [(buf.validate.field).uint64 = { gte: 10, lt: 5 }]; + // } + // ``` + uint64 gte = 5 [ + (predefined).cel = { + id: "uint64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyUInt64 { + // // value must be in list [1, 2, 3] + // uint64 value = 1 [(buf.validate.field).uint64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated uint64 in = 6 [(predefined).cel = { + id: "uint64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyUInt64 { + // // value must not be in list [1, 2, 3] + // uint64 value = 1 [(buf.validate.field).uint64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated uint64 not_in = 7 [(predefined).cel = { + id: "uint64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyUInt64 { + // uint64 value = 1 [ + // (buf.validate.field).uint64.example = 1, + // (buf.validate.field).uint64.example = -10 + // ]; + // } + // ``` + repeated uint64 example = 8 [(predefined).cel = { + id: "uint64.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// SInt32Rules describes the rules applied to `sint32` values. +message SInt32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must equal 42 + // sint32 value = 1 [(buf.validate.field).sint32.const = 42]; + // } + // ``` + optional sint32 const = 1 [(predefined).cel = { + id: "sint32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field + // < value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be less than 10 + // sint32 value = 1 [(buf.validate.field).sint32.lt = 10]; + // } + // ``` + sint32 lt = 2 [(predefined).cel = { + id: "sint32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be less than or equal to 10 + // sint32 value = 1 [(buf.validate.field).sint32.lte = 10]; + // } + // ``` + sint32 lte = 3 [(predefined).cel = { + id: "sint32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be greater than 5 [sint32.gt] + // sint32 value = 1 [(buf.validate.field).sint32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sint32.gt_lt] + // sint32 other_value = 2 [(buf.validate.field).sint32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sint32.gt_lt_exclusive] + // sint32 another_value = 3 [(buf.validate.field).sint32 = { gt: 10, lt: 5 }]; + // } + // ``` + sint32 gt = 4 [ + (predefined).cel = { + id: "sint32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be greater than or equal to 5 [sint32.gte] + // sint32 value = 1 [(buf.validate.field).sint32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sint32.gte_lt] + // sint32 other_value = 2 [(buf.validate.field).sint32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sint32.gte_lt_exclusive] + // sint32 another_value = 3 [(buf.validate.field).sint32 = { gte: 10, lt: 5 }]; + // } + // ``` + sint32 gte = 5 [ + (predefined).cel = { + id: "sint32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MySInt32 { + // // value must be in list [1, 2, 3] + // sint32 value = 1 [(buf.validate.field).sint32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sint32 in = 6 [(predefined).cel = { + id: "sint32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySInt32 { + // // value must not be in list [1, 2, 3] + // sint32 value = 1 [(buf.validate.field).sint32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sint32 not_in = 7 [(predefined).cel = { + id: "sint32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySInt32 { + // sint32 value = 1 [ + // (buf.validate.field).sint32.example = 1, + // (buf.validate.field).sint32.example = -10 + // ]; + // } + // ``` + repeated sint32 example = 8 [(predefined).cel = { + id: "sint32.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// SInt64Rules describes the rules applied to `sint64` values. +message SInt64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must equal 42 + // sint64 value = 1 [(buf.validate.field).sint64.const = 42]; + // } + // ``` + optional sint64 const = 1 [(predefined).cel = { + id: "sint64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field + // < value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be less than 10 + // sint64 value = 1 [(buf.validate.field).sint64.lt = 10]; + // } + // ``` + sint64 lt = 2 [(predefined).cel = { + id: "sint64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be less than or equal to 10 + // sint64 value = 1 [(buf.validate.field).sint64.lte = 10]; + // } + // ``` + sint64 lte = 3 [(predefined).cel = { + id: "sint64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be greater than 5 [sint64.gt] + // sint64 value = 1 [(buf.validate.field).sint64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sint64.gt_lt] + // sint64 other_value = 2 [(buf.validate.field).sint64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sint64.gt_lt_exclusive] + // sint64 another_value = 3 [(buf.validate.field).sint64 = { gt: 10, lt: 5 }]; + // } + // ``` + sint64 gt = 4 [ + (predefined).cel = { + id: "sint64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be greater than or equal to 5 [sint64.gte] + // sint64 value = 1 [(buf.validate.field).sint64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sint64.gte_lt] + // sint64 other_value = 2 [(buf.validate.field).sint64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sint64.gte_lt_exclusive] + // sint64 another_value = 3 [(buf.validate.field).sint64 = { gte: 10, lt: 5 }]; + // } + // ``` + sint64 gte = 5 [ + (predefined).cel = { + id: "sint64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message + // is generated. + // + // ```proto + // message MySInt64 { + // // value must be in list [1, 2, 3] + // sint64 value = 1 [(buf.validate.field).sint64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sint64 in = 6 [(predefined).cel = { + id: "sint64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySInt64 { + // // value must not be in list [1, 2, 3] + // sint64 value = 1 [(buf.validate.field).sint64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sint64 not_in = 7 [(predefined).cel = { + id: "sint64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySInt64 { + // sint64 value = 1 [ + // (buf.validate.field).sint64.example = 1, + // (buf.validate.field).sint64.example = -10 + // ]; + // } + // ``` + repeated sint64 example = 8 [(predefined).cel = { + id: "sint64.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// Fixed32Rules describes the rules applied to `fixed32` values. +message Fixed32Rules { + // `const` requires the field value to exactly match the specified value. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must equal 42 + // fixed32 value = 1 [(buf.validate.field).fixed32.const = 42]; + // } + // ``` + optional fixed32 const = 1 [(predefined).cel = { + id: "fixed32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be less than 10 + // fixed32 value = 1 [(buf.validate.field).fixed32.lt = 10]; + // } + // ``` + fixed32 lt = 2 [(predefined).cel = { + id: "fixed32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be less than or equal to 10 + // fixed32 value = 1 [(buf.validate.field).fixed32.lte = 10]; + // } + // ``` + fixed32 lte = 3 [(predefined).cel = { + id: "fixed32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be greater than 5 [fixed32.gt] + // fixed32 value = 1 [(buf.validate.field).fixed32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [fixed32.gt_lt] + // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [fixed32.gt_lt_exclusive] + // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gt: 10, lt: 5 }]; + // } + // ``` + fixed32 gt = 4 [ + (predefined).cel = { + id: "fixed32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be greater than or equal to 5 [fixed32.gte] + // fixed32 value = 1 [(buf.validate.field).fixed32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [fixed32.gte_lt] + // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [fixed32.gte_lt_exclusive] + // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gte: 10, lt: 5 }]; + // } + // ``` + fixed32 gte = 5 [ + (predefined).cel = { + id: "fixed32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message + // is generated. + // + // ```proto + // message MyFixed32 { + // // value must be in list [1, 2, 3] + // fixed32 value = 1 [(buf.validate.field).fixed32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated fixed32 in = 6 [(predefined).cel = { + id: "fixed32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyFixed32 { + // // value must not be in list [1, 2, 3] + // fixed32 value = 1 [(buf.validate.field).fixed32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated fixed32 not_in = 7 [(predefined).cel = { + id: "fixed32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFixed32 { + // fixed32 value = 1 [ + // (buf.validate.field).fixed32.example = 1, + // (buf.validate.field).fixed32.example = 2 + // ]; + // } + // ``` + repeated fixed32 example = 8 [(predefined).cel = { + id: "fixed32.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// Fixed64Rules describes the rules applied to `fixed64` values. +message Fixed64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must equal 42 + // fixed64 value = 1 [(buf.validate.field).fixed64.const = 42]; + // } + // ``` + optional fixed64 const = 1 [(predefined).cel = { + id: "fixed64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be less than 10 + // fixed64 value = 1 [(buf.validate.field).fixed64.lt = 10]; + // } + // ``` + fixed64 lt = 2 [(predefined).cel = { + id: "fixed64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be less than or equal to 10 + // fixed64 value = 1 [(buf.validate.field).fixed64.lte = 10]; + // } + // ``` + fixed64 lte = 3 [(predefined).cel = { + id: "fixed64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be greater than 5 [fixed64.gt] + // fixed64 value = 1 [(buf.validate.field).fixed64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [fixed64.gt_lt] + // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [fixed64.gt_lt_exclusive] + // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gt: 10, lt: 5 }]; + // } + // ``` + fixed64 gt = 4 [ + (predefined).cel = { + id: "fixed64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be greater than or equal to 5 [fixed64.gte] + // fixed64 value = 1 [(buf.validate.field).fixed64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [fixed64.gte_lt] + // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [fixed64.gte_lt_exclusive] + // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gte: 10, lt: 5 }]; + // } + // ``` + fixed64 gte = 5 [ + (predefined).cel = { + id: "fixed64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyFixed64 { + // // value must be in list [1, 2, 3] + // fixed64 value = 1 [(buf.validate.field).fixed64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated fixed64 in = 6 [(predefined).cel = { + id: "fixed64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyFixed64 { + // // value must not be in list [1, 2, 3] + // fixed64 value = 1 [(buf.validate.field).fixed64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated fixed64 not_in = 7 [(predefined).cel = { + id: "fixed64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFixed64 { + // fixed64 value = 1 [ + // (buf.validate.field).fixed64.example = 1, + // (buf.validate.field).fixed64.example = 2 + // ]; + // } + // ``` + repeated fixed64 example = 8 [(predefined).cel = { + id: "fixed64.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// SFixed32Rules describes the rules applied to `fixed32` values. +message SFixed32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must equal 42 + // sfixed32 value = 1 [(buf.validate.field).sfixed32.const = 42]; + // } + // ``` + optional sfixed32 const = 1 [(predefined).cel = { + id: "sfixed32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be less than 10 + // sfixed32 value = 1 [(buf.validate.field).sfixed32.lt = 10]; + // } + // ``` + sfixed32 lt = 2 [(predefined).cel = { + id: "sfixed32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be less than or equal to 10 + // sfixed32 value = 1 [(buf.validate.field).sfixed32.lte = 10]; + // } + // ``` + sfixed32 lte = 3 [(predefined).cel = { + id: "sfixed32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be greater than 5 [sfixed32.gt] + // sfixed32 value = 1 [(buf.validate.field).sfixed32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sfixed32.gt_lt] + // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sfixed32.gt_lt_exclusive] + // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gt: 10, lt: 5 }]; + // } + // ``` + sfixed32 gt = 4 [ + (predefined).cel = { + id: "sfixed32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be greater than or equal to 5 [sfixed32.gte] + // sfixed32 value = 1 [(buf.validate.field).sfixed32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sfixed32.gte_lt] + // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sfixed32.gte_lt_exclusive] + // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gte: 10, lt: 5 }]; + // } + // ``` + sfixed32 gte = 5 [ + (predefined).cel = { + id: "sfixed32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MySFixed32 { + // // value must be in list [1, 2, 3] + // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed32 in = 6 [(predefined).cel = { + id: "sfixed32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySFixed32 { + // // value must not be in list [1, 2, 3] + // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed32 not_in = 7 [(predefined).cel = { + id: "sfixed32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySFixed32 { + // sfixed32 value = 1 [ + // (buf.validate.field).sfixed32.example = 1, + // (buf.validate.field).sfixed32.example = 2 + // ]; + // } + // ``` + repeated sfixed32 example = 8 [(predefined).cel = { + id: "sfixed32.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// SFixed64Rules describes the rules applied to `fixed64` values. +message SFixed64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must equal 42 + // sfixed64 value = 1 [(buf.validate.field).sfixed64.const = 42]; + // } + // ``` + optional sfixed64 const = 1 [(predefined).cel = { + id: "sfixed64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be less than 10 + // sfixed64 value = 1 [(buf.validate.field).sfixed64.lt = 10]; + // } + // ``` + sfixed64 lt = 2 [(predefined).cel = { + id: "sfixed64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be less than or equal to 10 + // sfixed64 value = 1 [(buf.validate.field).sfixed64.lte = 10]; + // } + // ``` + sfixed64 lte = 3 [(predefined).cel = { + id: "sfixed64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be greater than 5 [sfixed64.gt] + // sfixed64 value = 1 [(buf.validate.field).sfixed64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sfixed64.gt_lt] + // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sfixed64.gt_lt_exclusive] + // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gt: 10, lt: 5 }]; + // } + // ``` + sfixed64 gt = 4 [ + (predefined).cel = { + id: "sfixed64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be greater than or equal to 5 [sfixed64.gte] + // sfixed64 value = 1 [(buf.validate.field).sfixed64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sfixed64.gte_lt] + // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sfixed64.gte_lt_exclusive] + // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gte: 10, lt: 5 }]; + // } + // ``` + sfixed64 gte = 5 [ + (predefined).cel = { + id: "sfixed64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MySFixed64 { + // // value must be in list [1, 2, 3] + // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed64 in = 6 [(predefined).cel = { + id: "sfixed64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySFixed64 { + // // value must not be in list [1, 2, 3] + // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed64 not_in = 7 [(predefined).cel = { + id: "sfixed64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySFixed64 { + // sfixed64 value = 1 [ + // (buf.validate.field).sfixed64.example = 1, + // (buf.validate.field).sfixed64.example = 2 + // ]; + // } + // ``` + repeated sfixed64 example = 8 [(predefined).cel = { + id: "sfixed64.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// BoolRules describes the rules applied to `bool` values. These rules +// may also be applied to the `google.protobuf.BoolValue` Well-Known-Type. +message BoolRules { + // `const` requires the field value to exactly match the specified boolean value. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyBool { + // // value must equal true + // bool value = 1 [(buf.validate.field).bool.const = true]; + // } + // ``` + optional bool const = 1 [(predefined).cel = { + id: "bool.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyBool { + // bool value = 1 [ + // (buf.validate.field).bool.example = 1, + // (buf.validate.field).bool.example = 2 + // ]; + // } + // ``` + repeated bool example = 2 [(predefined).cel = { + id: "bool.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// StringRules describes the rules applied to `string` values These +// rules may also be applied to the `google.protobuf.StringValue` Well-Known-Type. +message StringRules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyString { + // // value must equal `hello` + // string value = 1 [(buf.validate.field).string.const = "hello"]; + // } + // ``` + optional string const = 1 [(predefined).cel = { + id: "string.const" + expression: "this != getField(rules, 'const') ? 'value must equal `%s`'.format([getField(rules, 'const')]) : ''" + }]; + + // `len` dictates that the field value must have the specified + // number of characters (Unicode code points), which may differ from the number + // of bytes in the string. If the field value does not meet the specified + // length, an error message will be generated. + // + // ```proto + // message MyString { + // // value length must be 5 characters + // string value = 1 [(buf.validate.field).string.len = 5]; + // } + // ``` + optional uint64 len = 19 [(predefined).cel = { + id: "string.len" + expression: "uint(this.size()) != rules.len ? 'value length must be %s characters'.format([rules.len]) : ''" + }]; + + // `min_len` specifies that the field value must have at least the specified + // number of characters (Unicode code points), which may differ from the number + // of bytes in the string. If the field value contains fewer characters, an error + // message will be generated. + // + // ```proto + // message MyString { + // // value length must be at least 3 characters + // string value = 1 [(buf.validate.field).string.min_len = 3]; + // } + // ``` + optional uint64 min_len = 2 [(predefined).cel = { + id: "string.min_len" + expression: "uint(this.size()) < rules.min_len ? 'value length must be at least %s characters'.format([rules.min_len]) : ''" + }]; + + // `max_len` specifies that the field value must have no more than the specified + // number of characters (Unicode code points), which may differ from the + // number of bytes in the string. If the field value contains more characters, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value length must be at most 10 characters + // string value = 1 [(buf.validate.field).string.max_len = 10]; + // } + // ``` + optional uint64 max_len = 3 [(predefined).cel = { + id: "string.max_len" + expression: "uint(this.size()) > rules.max_len ? 'value length must be at most %s characters'.format([rules.max_len]) : ''" + }]; + + // `len_bytes` dictates that the field value must have the specified number of + // bytes. If the field value does not match the specified length in bytes, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value length must be 6 bytes + // string value = 1 [(buf.validate.field).string.len_bytes = 6]; + // } + // ``` + optional uint64 len_bytes = 20 [(predefined).cel = { + id: "string.len_bytes" + expression: "uint(bytes(this).size()) != rules.len_bytes ? 'value length must be %s bytes'.format([rules.len_bytes]) : ''" + }]; + + // `min_bytes` specifies that the field value must have at least the specified + // number of bytes. If the field value contains fewer bytes, an error message + // will be generated. + // + // ```proto + // message MyString { + // // value length must be at least 4 bytes + // string value = 1 [(buf.validate.field).string.min_bytes = 4]; + // } + // + // ``` + optional uint64 min_bytes = 4 [(predefined).cel = { + id: "string.min_bytes" + expression: "uint(bytes(this).size()) < rules.min_bytes ? 'value length must be at least %s bytes'.format([rules.min_bytes]) : ''" + }]; + + // `max_bytes` specifies that the field value must have no more than the + //specified number of bytes. If the field value contains more bytes, an + // error message will be generated. + // + // ```proto + // message MyString { + // // value length must be at most 8 bytes + // string value = 1 [(buf.validate.field).string.max_bytes = 8]; + // } + // ``` + optional uint64 max_bytes = 5 [(predefined).cel = { + id: "string.max_bytes" + expression: "uint(bytes(this).size()) > rules.max_bytes ? 'value length must be at most %s bytes'.format([rules.max_bytes]) : ''" + }]; + + // `pattern` specifies that the field value must match the specified + // regular expression (RE2 syntax), with the expression provided without any + // delimiters. If the field value doesn't match the regular expression, an + // error message will be generated. + // + // ```proto + // message MyString { + // // value does not match regex pattern `^[a-zA-Z]//$` + // string value = 1 [(buf.validate.field).string.pattern = "^[a-zA-Z]//$"]; + // } + // ``` + optional string pattern = 6 [(predefined).cel = { + id: "string.pattern" + expression: "!this.matches(rules.pattern) ? 'value does not match regex pattern `%s`'.format([rules.pattern]) : ''" + }]; + + // `prefix` specifies that the field value must have the + //specified substring at the beginning of the string. If the field value + // doesn't start with the specified prefix, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value does not have prefix `pre` + // string value = 1 [(buf.validate.field).string.prefix = "pre"]; + // } + // ``` + optional string prefix = 7 [(predefined).cel = { + id: "string.prefix" + expression: "!this.startsWith(rules.prefix) ? 'value does not have prefix `%s`'.format([rules.prefix]) : ''" + }]; + + // `suffix` specifies that the field value must have the + //specified substring at the end of the string. If the field value doesn't + // end with the specified suffix, an error message will be generated. + // + // ```proto + // message MyString { + // // value does not have suffix `post` + // string value = 1 [(buf.validate.field).string.suffix = "post"]; + // } + // ``` + optional string suffix = 8 [(predefined).cel = { + id: "string.suffix" + expression: "!this.endsWith(rules.suffix) ? 'value does not have suffix `%s`'.format([rules.suffix]) : ''" + }]; + + // `contains` specifies that the field value must have the + //specified substring anywhere in the string. If the field value doesn't + // contain the specified substring, an error message will be generated. + // + // ```proto + // message MyString { + // // value does not contain substring `inside`. + // string value = 1 [(buf.validate.field).string.contains = "inside"]; + // } + // ``` + optional string contains = 9 [(predefined).cel = { + id: "string.contains" + expression: "!this.contains(rules.contains) ? 'value does not contain substring `%s`'.format([rules.contains]) : ''" + }]; + + // `not_contains` specifies that the field value must not have the + //specified substring anywhere in the string. If the field value contains + // the specified substring, an error message will be generated. + // + // ```proto + // message MyString { + // // value contains substring `inside`. + // string value = 1 [(buf.validate.field).string.not_contains = "inside"]; + // } + // ``` + optional string not_contains = 23 [(predefined).cel = { + id: "string.not_contains" + expression: "this.contains(rules.not_contains) ? 'value contains substring `%s`'.format([rules.not_contains]) : ''" + }]; + + // `in` specifies that the field value must be equal to one of the specified + // values. If the field value isn't one of the specified values, an error + // message will be generated. + // + // ```proto + // message MyString { + // // value must be in list ["apple", "banana"] + // string value = 1 [(buf.validate.field).string.in = "apple", (buf.validate.field).string.in = "banana"]; + // } + // ``` + repeated string in = 10 [(predefined).cel = { + id: "string.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` specifies that the field value cannot be equal to any + // of the specified values. If the field value is one of the specified values, + // an error message will be generated. + // ```proto + // message MyString { + // // value must not be in list ["orange", "grape"] + // string value = 1 [(buf.validate.field).string.not_in = "orange", (buf.validate.field).string.not_in = "grape"]; + // } + // ``` + repeated string not_in = 11 [(predefined).cel = { + id: "string.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `WellKnown` rules provide advanced rules against common string + // patterns. + oneof well_known { + // `email` specifies that the field value must be a valid email address, for + // example "foo@example.com". + // + // Conforms to the definition for a valid email address from the [HTML standard](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address). + // Note that this standard willfully deviates from [RFC 5322](https://datatracker.ietf.org/doc/html/rfc5322), + // which allows many unexpected forms of email addresses and will easily match + // a typographical error. + // + // If the field value isn't a valid email address, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid email address + // string value = 1 [(buf.validate.field).string.email = true]; + // } + // ``` + bool email = 12 [ + (predefined).cel = { + id: "string.email" + message: "value must be a valid email address" + expression: "!rules.email || this == '' || this.isEmail()" + }, + (predefined).cel = { + id: "string.email_empty" + message: "value is empty, which is not a valid email address" + expression: "!rules.email || this != ''" + } + ]; + + // `hostname` specifies that the field value must be a valid hostname, for + // example "foo.example.com". + // + // A valid hostname follows the rules below: + // - The name consists of one or more labels, separated by a dot ("."). + // - Each label can be 1 to 63 alphanumeric characters. + // - A label can contain hyphens ("-"), but must not start or end with a hyphen. + // - The right-most label must not be digits only. + // - The name can have a trailing dot—for example, "foo.example.com.". + // - The name can be 253 characters at most, excluding the optional trailing dot. + // + // If the field value isn't a valid hostname, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid hostname + // string value = 1 [(buf.validate.field).string.hostname = true]; + // } + // ``` + bool hostname = 13 [ + (predefined).cel = { + id: "string.hostname" + message: "value must be a valid hostname" + expression: "!rules.hostname || this == '' || this.isHostname()" + }, + (predefined).cel = { + id: "string.hostname_empty" + message: "value is empty, which is not a valid hostname" + expression: "!rules.hostname || this != ''" + } + ]; + + // `ip` specifies that the field value must be a valid IP (v4 or v6) address. + // + // IPv4 addresses are expected in the dotted decimal format—for example, "192.168.5.21". + // IPv6 addresses are expected in their text representation—for example, "::1", + // or "2001:0DB8:ABCD:0012::0". + // + // Both formats are well-defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). + // Zone identifiers for IPv6 addresses (for example, "fe80::a%en1") are supported. + // + // If the field value isn't a valid IP address, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid IP address + // string value = 1 [(buf.validate.field).string.ip = true]; + // } + // ``` + bool ip = 14 [ + (predefined).cel = { + id: "string.ip" + message: "value must be a valid IP address" + expression: "!rules.ip || this == '' || this.isIp()" + }, + (predefined).cel = { + id: "string.ip_empty" + message: "value is empty, which is not a valid IP address" + expression: "!rules.ip || this != ''" + } + ]; + + // `ipv4` specifies that the field value must be a valid IPv4 address—for + // example "192.168.5.21". If the field value isn't a valid IPv4 address, an + // error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv4 address + // string value = 1 [(buf.validate.field).string.ipv4 = true]; + // } + // ``` + bool ipv4 = 15 [ + (predefined).cel = { + id: "string.ipv4" + message: "value must be a valid IPv4 address" + expression: "!rules.ipv4 || this == '' || this.isIp(4)" + }, + (predefined).cel = { + id: "string.ipv4_empty" + message: "value is empty, which is not a valid IPv4 address" + expression: "!rules.ipv4 || this != ''" + } + ]; + + // `ipv6` specifies that the field value must be a valid IPv6 address—for + // example "::1", or "d7a:115c:a1e0:ab12:4843:cd96:626b:430b". If the field + // value is not a valid IPv6 address, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv6 address + // string value = 1 [(buf.validate.field).string.ipv6 = true]; + // } + // ``` + bool ipv6 = 16 [ + (predefined).cel = { + id: "string.ipv6" + message: "value must be a valid IPv6 address" + expression: "!rules.ipv6 || this == '' || this.isIp(6)" + }, + (predefined).cel = { + id: "string.ipv6_empty" + message: "value is empty, which is not a valid IPv6 address" + expression: "!rules.ipv6 || this != ''" + } + ]; + + // `uri` specifies that the field value must be a valid URI, for example + // "https://example.com/foo/bar?baz=quux#frag". + // + // URI is defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). + // Zone Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)). + // + // If the field value isn't a valid URI, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid URI + // string value = 1 [(buf.validate.field).string.uri = true]; + // } + // ``` + bool uri = 17 [ + (predefined).cel = { + id: "string.uri" + message: "value must be a valid URI" + expression: "!rules.uri || this == '' || this.isUri()" + }, + (predefined).cel = { + id: "string.uri_empty" + message: "value is empty, which is not a valid URI" + expression: "!rules.uri || this != ''" + } + ]; + + // `uri_ref` specifies that the field value must be a valid URI Reference—either + // a URI such as "https://example.com/foo/bar?baz=quux#frag", or a Relative + // Reference such as "./foo/bar?query". + // + // URI, URI Reference, and Relative Reference are defined in the internet + // standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). Zone + // Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)). + // + // If the field value isn't a valid URI Reference, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid URI Reference + // string value = 1 [(buf.validate.field).string.uri_ref = true]; + // } + // ``` + bool uri_ref = 18 [(predefined).cel = { + id: "string.uri_ref" + message: "value must be a valid URI Reference" + expression: "!rules.uri_ref || this.isUriRef()" + }]; + + // `address` specifies that the field value must be either a valid hostname + // (for example, "example.com"), or a valid IP (v4 or v6) address (for example, + // "192.168.0.1", or "::1"). If the field value isn't a valid hostname or IP, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid hostname, or ip address + // string value = 1 [(buf.validate.field).string.address = true]; + // } + // ``` + bool address = 21 [ + (predefined).cel = { + id: "string.address" + message: "value must be a valid hostname, or ip address" + expression: "!rules.address || this == '' || this.isHostname() || this.isIp()" + }, + (predefined).cel = { + id: "string.address_empty" + message: "value is empty, which is not a valid hostname, or ip address" + expression: "!rules.address || this != ''" + } + ]; + + // `uuid` specifies that the field value must be a valid UUID as defined by + // [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). If the + // field value isn't a valid UUID, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid UUID + // string value = 1 [(buf.validate.field).string.uuid = true]; + // } + // ``` + bool uuid = 22 [ + (predefined).cel = { + id: "string.uuid" + message: "value must be a valid UUID" + expression: "!rules.uuid || this == '' || this.matches('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')" + }, + (predefined).cel = { + id: "string.uuid_empty" + message: "value is empty, which is not a valid UUID" + expression: "!rules.uuid || this != ''" + } + ]; + + // `tuuid` (trimmed UUID) specifies that the field value must be a valid UUID as + // defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2) with all dashes + // omitted. If the field value isn't a valid UUID without dashes, an error message + // will be generated. + // + // ```proto + // message MyString { + // // value must be a valid trimmed UUID + // string value = 1 [(buf.validate.field).string.tuuid = true]; + // } + // ``` + bool tuuid = 33 [ + (predefined).cel = { + id: "string.tuuid" + message: "value must be a valid trimmed UUID" + expression: "!rules.tuuid || this == '' || this.matches('^[0-9a-fA-F]{32}$')" + }, + (predefined).cel = { + id: "string.tuuid_empty" + message: "value is empty, which is not a valid trimmed UUID" + expression: "!rules.tuuid || this != ''" + } + ]; + + // `ip_with_prefixlen` specifies that the field value must be a valid IP + // (v4 or v6) address with prefix length—for example, "192.168.5.21/16" or + // "2001:0DB8:ABCD:0012::F1/64". If the field value isn't a valid IP with + // prefix length, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IP with prefix length + // string value = 1 [(buf.validate.field).string.ip_with_prefixlen = true]; + // } + // ``` + bool ip_with_prefixlen = 26 [ + (predefined).cel = { + id: "string.ip_with_prefixlen" + message: "value must be a valid IP prefix" + expression: "!rules.ip_with_prefixlen || this == '' || this.isIpPrefix()" + }, + (predefined).cel = { + id: "string.ip_with_prefixlen_empty" + message: "value is empty, which is not a valid IP prefix" + expression: "!rules.ip_with_prefixlen || this != ''" + } + ]; + + // `ipv4_with_prefixlen` specifies that the field value must be a valid + // IPv4 address with prefix length—for example, "192.168.5.21/16". If the + // field value isn't a valid IPv4 address with prefix length, an error + // message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv4 address with prefix length + // string value = 1 [(buf.validate.field).string.ipv4_with_prefixlen = true]; + // } + // ``` + bool ipv4_with_prefixlen = 27 [ + (predefined).cel = { + id: "string.ipv4_with_prefixlen" + message: "value must be a valid IPv4 address with prefix length" + expression: "!rules.ipv4_with_prefixlen || this == '' || this.isIpPrefix(4)" + }, + (predefined).cel = { + id: "string.ipv4_with_prefixlen_empty" + message: "value is empty, which is not a valid IPv4 address with prefix length" + expression: "!rules.ipv4_with_prefixlen || this != ''" + } + ]; + + // `ipv6_with_prefixlen` specifies that the field value must be a valid + // IPv6 address with prefix length—for example, "2001:0DB8:ABCD:0012::F1/64". + // If the field value is not a valid IPv6 address with prefix length, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv6 address prefix length + // string value = 1 [(buf.validate.field).string.ipv6_with_prefixlen = true]; + // } + // ``` + bool ipv6_with_prefixlen = 28 [ + (predefined).cel = { + id: "string.ipv6_with_prefixlen" + message: "value must be a valid IPv6 address with prefix length" + expression: "!rules.ipv6_with_prefixlen || this == '' || this.isIpPrefix(6)" + }, + (predefined).cel = { + id: "string.ipv6_with_prefixlen_empty" + message: "value is empty, which is not a valid IPv6 address with prefix length" + expression: "!rules.ipv6_with_prefixlen || this != ''" + } + ]; + + // `ip_prefix` specifies that the field value must be a valid IP (v4 or v6) + // prefix—for example, "192.168.0.0/16" or "2001:0DB8:ABCD:0012::0/64". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the + // prefix, and the remaining 64 bits must be zero. + // + // If the field value isn't a valid IP prefix, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid IP prefix + // string value = 1 [(buf.validate.field).string.ip_prefix = true]; + // } + // ``` + bool ip_prefix = 29 [ + (predefined).cel = { + id: "string.ip_prefix" + message: "value must be a valid IP prefix" + expression: "!rules.ip_prefix || this == '' || this.isIpPrefix(true)" + }, + (predefined).cel = { + id: "string.ip_prefix_empty" + message: "value is empty, which is not a valid IP prefix" + expression: "!rules.ip_prefix || this != ''" + } + ]; + + // `ipv4_prefix` specifies that the field value must be a valid IPv4 + // prefix, for example "192.168.0.0/16". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "192.168.0.0/16" designates the left-most 16 bits for the prefix, + // and the remaining 16 bits must be zero. + // + // If the field value isn't a valid IPv4 prefix, an error message + // will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv4 prefix + // string value = 1 [(buf.validate.field).string.ipv4_prefix = true]; + // } + // ``` + bool ipv4_prefix = 30 [ + (predefined).cel = { + id: "string.ipv4_prefix" + message: "value must be a valid IPv4 prefix" + expression: "!rules.ipv4_prefix || this == '' || this.isIpPrefix(4, true)" + }, + (predefined).cel = { + id: "string.ipv4_prefix_empty" + message: "value is empty, which is not a valid IPv4 prefix" + expression: "!rules.ipv4_prefix || this != ''" + } + ]; + + // `ipv6_prefix` specifies that the field value must be a valid IPv6 prefix—for + // example, "2001:0DB8:ABCD:0012::0/64". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the + // prefix, and the remaining 64 bits must be zero. + // + // If the field value is not a valid IPv6 prefix, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv6 prefix + // string value = 1 [(buf.validate.field).string.ipv6_prefix = true]; + // } + // ``` + bool ipv6_prefix = 31 [ + (predefined).cel = { + id: "string.ipv6_prefix" + message: "value must be a valid IPv6 prefix" + expression: "!rules.ipv6_prefix || this == '' || this.isIpPrefix(6, true)" + }, + (predefined).cel = { + id: "string.ipv6_prefix_empty" + message: "value is empty, which is not a valid IPv6 prefix" + expression: "!rules.ipv6_prefix || this != ''" + } + ]; + + // `host_and_port` specifies that the field value must be valid host/port + // pair—for example, "example.com:8080". + // + // The host can be one of: + //- An IPv4 address in dotted decimal format—for example, "192.168.5.21". + //- An IPv6 address enclosed in square brackets—for example, "[2001:0DB8:ABCD:0012::F1]". + //- A hostname—for example, "example.com". + // + // The port is separated by a colon. It must be non-empty, with a decimal number + // in the range of 0-65535, inclusive. + bool host_and_port = 32 [ + (predefined).cel = { + id: "string.host_and_port" + message: "value must be a valid host (hostname or IP address) and port pair" + expression: "!rules.host_and_port || this == '' || this.isHostAndPort(true)" + }, + (predefined).cel = { + id: "string.host_and_port_empty" + message: "value is empty, which is not a valid host and port pair" + expression: "!rules.host_and_port || this != ''" + } + ]; + + // `ulid` specifies that the field value must be a valid ULID (Universally Unique + // Lexicographically Sortable Identifier) as defined by the [ULID specification](https://github.com/ulid/spec). + // If the field value isn't a valid ULID, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid ULID + // string value = 1 [(buf.validate.field).string.ulid = true]; + // } + // ``` + bool ulid = 35 [ + (predefined).cel = { + id: "string.ulid" + message: "value must be a valid ULID" + expression: "!rules.ulid || this == '' || this.matches('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$')" + }, + (predefined).cel = { + id: "string.ulid_empty" + message: "value is empty, which is not a valid ULID" + expression: "!rules.ulid || this != ''" + } + ]; + + // `well_known_regex` specifies a common well-known pattern + // defined as a regex. If the field value doesn't match the well-known + // regex, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid HTTP header value + // string value = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_VALUE]; + // } + // ``` + // + // #### KnownRegex + // + // `well_known_regex` contains some well-known patterns. + // + // | Name | Number | Description | + // |-------------------------------|--------|-------------------------------------------| + // | KNOWN_REGEX_UNSPECIFIED | 0 | | + // | KNOWN_REGEX_HTTP_HEADER_NAME | 1 | HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2) | + // | KNOWN_REGEX_HTTP_HEADER_VALUE | 2 | HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4) | + KnownRegex well_known_regex = 24 [ + (predefined).cel = { + id: "string.well_known_regex.header_name" + message: "value must be a valid HTTP header name" + expression: + "rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?" + "'^:?[0-9a-zA-Z!#$%&\\'*+-.^_|~\\x60]+$' :" + "'^[^\\u0000\\u000A\\u000D]+$')" + }, + (predefined).cel = { + id: "string.well_known_regex.header_name_empty" + message: "value is empty, which is not a valid HTTP header name" + expression: "rules.well_known_regex != 1 || this != ''" + }, + (predefined).cel = { + id: "string.well_known_regex.header_value" + message: "value must be a valid HTTP header value" + expression: + "rules.well_known_regex != 2 || this.matches(!has(rules.strict) || rules.strict ?" + "'^[^\\u0000-\\u0008\\u000A-\\u001F\\u007F]*$' :" + "'^[^\\u0000\\u000A\\u000D]*$')" + } + ]; + } + + // This applies to regexes `HTTP_HEADER_NAME` and `HTTP_HEADER_VALUE` to + // enable strict header validation. By default, this is true, and HTTP header + // validations are [RFC-compliant](https://datatracker.ietf.org/doc/html/rfc7230#section-3). Setting to false will enable looser + // validations that only disallow `\r\n\0` characters, which can be used to + // bypass header matching rules. + // + // ```proto + // message MyString { + // // The field `value` must have be a valid HTTP headers, but not enforced with strict rules. + // string value = 1 [(buf.validate.field).string.strict = false]; + // } + // ``` + optional bool strict = 25; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyString { + // string value = 1 [ + // (buf.validate.field).string.example = "hello", + // (buf.validate.field).string.example = "world" + // ]; + // } + // ``` + repeated string example = 34 [(predefined).cel = { + id: "string.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// KnownRegex contains some well-known patterns. +enum KnownRegex { + KNOWN_REGEX_UNSPECIFIED = 0; + + // HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2). + KNOWN_REGEX_HTTP_HEADER_NAME = 1; + + // HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4). + KNOWN_REGEX_HTTP_HEADER_VALUE = 2; +} + +// BytesRules describe the rules applied to `bytes` values. These rules +// may also be applied to the `google.protobuf.BytesValue` Well-Known-Type. +message BytesRules { + // `const` requires the field value to exactly match the specified bytes + // value. If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be "\x01\x02\x03\x04" + // bytes value = 1 [(buf.validate.field).bytes.const = "\x01\x02\x03\x04"]; + // } + // ``` + optional bytes const = 1 [(predefined).cel = { + id: "bytes.const" + expression: "this != getField(rules, 'const') ? 'value must be %x'.format([getField(rules, 'const')]) : ''" + }]; + + // `len` requires the field value to have the specified length in bytes. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyBytes { + // // value length must be 4 bytes. + // optional bytes value = 1 [(buf.validate.field).bytes.len = 4]; + // } + // ``` + optional uint64 len = 13 [(predefined).cel = { + id: "bytes.len" + expression: "uint(this.size()) != rules.len ? 'value length must be %s bytes'.format([rules.len]) : ''" + }]; + + // `min_len` requires the field value to have at least the specified minimum + // length in bytes. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value length must be at least 2 bytes. + // optional bytes value = 1 [(buf.validate.field).bytes.min_len = 2]; + // } + // ``` + optional uint64 min_len = 2 [(predefined).cel = { + id: "bytes.min_len" + expression: "uint(this.size()) < rules.min_len ? 'value length must be at least %s bytes'.format([rules.min_len]) : ''" + }]; + + // `max_len` requires the field value to have at most the specified maximum + // length in bytes. + // If the field value exceeds the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be at most 6 bytes. + // optional bytes value = 1 [(buf.validate.field).bytes.max_len = 6]; + // } + // ``` + optional uint64 max_len = 3 [(predefined).cel = { + id: "bytes.max_len" + expression: "uint(this.size()) > rules.max_len ? 'value must be at most %s bytes'.format([rules.max_len]) : ''" + }]; + + // `pattern` requires the field value to match the specified regular + // expression ([RE2 syntax](https://github.com/google/re2/wiki/Syntax)). + // The value of the field must be valid UTF-8 or validation will fail with a + // runtime error. + // If the field value doesn't match the pattern, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must match regex pattern "^[a-zA-Z0-9]+$". + // optional bytes value = 1 [(buf.validate.field).bytes.pattern = "^[a-zA-Z0-9]+$"]; + // } + // ``` + optional string pattern = 4 [(predefined).cel = { + id: "bytes.pattern" + expression: "!string(this).matches(rules.pattern) ? 'value must match regex pattern `%s`'.format([rules.pattern]) : ''" + }]; + + // `prefix` requires the field value to have the specified bytes at the + // beginning of the string. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value does not have prefix \x01\x02 + // optional bytes value = 1 [(buf.validate.field).bytes.prefix = "\x01\x02"]; + // } + // ``` + optional bytes prefix = 5 [(predefined).cel = { + id: "bytes.prefix" + expression: "!this.startsWith(rules.prefix) ? 'value does not have prefix %x'.format([rules.prefix]) : ''" + }]; + + // `suffix` requires the field value to have the specified bytes at the end + // of the string. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value does not have suffix \x03\x04 + // optional bytes value = 1 [(buf.validate.field).bytes.suffix = "\x03\x04"]; + // } + // ``` + optional bytes suffix = 6 [(predefined).cel = { + id: "bytes.suffix" + expression: "!this.endsWith(rules.suffix) ? 'value does not have suffix %x'.format([rules.suffix]) : ''" + }]; + + // `contains` requires the field value to have the specified bytes anywhere in + // the string. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value does not contain \x02\x03 + // optional bytes value = 1 [(buf.validate.field).bytes.contains = "\x02\x03"]; + // } + // ``` + optional bytes contains = 7 [(predefined).cel = { + id: "bytes.contains" + expression: "!this.contains(rules.contains) ? 'value does not contain %x'.format([rules.contains]) : ''" + }]; + + // `in` requires the field value to be equal to one of the specified + // values. If the field value doesn't match any of the specified values, an + // error message is generated. + // + // ```proto + // message MyBytes { + // // value must in ["\x01\x02", "\x02\x03", "\x03\x04"] + // optional bytes value = 1 [(buf.validate.field).bytes.in = {"\x01\x02", "\x02\x03", "\x03\x04"}]; + // } + // ``` + repeated bytes in = 8 [(predefined).cel = { + id: "bytes.in" + expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to be not equal to any of the specified + // values. + // If the field value matches any of the specified values, an error message is + // generated. + // + // ```proto + // message MyBytes { + // // value must not in ["\x01\x02", "\x02\x03", "\x03\x04"] + // optional bytes value = 1 [(buf.validate.field).bytes.not_in = {"\x01\x02", "\x02\x03", "\x03\x04"}]; + // } + // ``` + repeated bytes not_in = 9 [(predefined).cel = { + id: "bytes.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // WellKnown rules provide advanced rules against common byte + // patterns + oneof well_known { + // `ip` ensures that the field `value` is a valid IP address (v4 or v6) in byte format. + // If the field value doesn't meet this rule, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be a valid IP address + // optional bytes value = 1 [(buf.validate.field).bytes.ip = true]; + // } + // ``` + bool ip = 10 [ + (predefined).cel = { + id: "bytes.ip" + message: "value must be a valid IP address" + expression: "!rules.ip || this.size() == 0 || this.size() == 4 || this.size() == 16" + }, + (predefined).cel = { + id: "bytes.ip_empty" + message: "value is empty, which is not a valid IP address" + expression: "!rules.ip || this.size() != 0" + } + ]; + + // `ipv4` ensures that the field `value` is a valid IPv4 address in byte format. + // If the field value doesn't meet this rule, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be a valid IPv4 address + // optional bytes value = 1 [(buf.validate.field).bytes.ipv4 = true]; + // } + // ``` + bool ipv4 = 11 [ + (predefined).cel = { + id: "bytes.ipv4" + message: "value must be a valid IPv4 address" + expression: "!rules.ipv4 || this.size() == 0 || this.size() == 4" + }, + (predefined).cel = { + id: "bytes.ipv4_empty" + message: "value is empty, which is not a valid IPv4 address" + expression: "!rules.ipv4 || this.size() != 0" + } + ]; + + // `ipv6` ensures that the field `value` is a valid IPv6 address in byte format. + // If the field value doesn't meet this rule, an error message is generated. + // ```proto + // message MyBytes { + // // value must be a valid IPv6 address + // optional bytes value = 1 [(buf.validate.field).bytes.ipv6 = true]; + // } + // ``` + bool ipv6 = 12 [ + (predefined).cel = { + id: "bytes.ipv6" + message: "value must be a valid IPv6 address" + expression: "!rules.ipv6 || this.size() == 0 || this.size() == 16" + }, + (predefined).cel = { + id: "bytes.ipv6_empty" + message: "value is empty, which is not a valid IPv6 address" + expression: "!rules.ipv6 || this.size() != 0" + } + ]; + + // `uuid` ensures that the field `value` encodes the 128-bit UUID data as + // defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). + // The field must contain exactly 16 bytes + // representing the UUID. If the field value isn't a valid UUID, an error + // message will be generated. + // + // ```proto + // message MyBytes { + // // value must be a valid UUID + // optional bytes value = 1 [(buf.validate.field).bytes.uuid = true]; + // } + // ``` + bool uuid = 15 [ + (predefined).cel = { + id: "bytes.uuid" + message: "value must be a valid UUID" + expression: "!rules.uuid || this.size() == 0 || this.size() == 16" + }, + (predefined).cel = { + id: "bytes.uuid_empty" + message: "value is empty, which is not a valid UUID" + expression: "!rules.uuid || this.size() != 0" + } + ]; + } + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyBytes { + // bytes value = 1 [ + // (buf.validate.field).bytes.example = "\x01\x02", + // (buf.validate.field).bytes.example = "\x02\x03" + // ]; + // } + // ``` + repeated bytes example = 14 [(predefined).cel = { + id: "bytes.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// EnumRules describe the rules applied to `enum` values. +message EnumRules { + // `const` requires the field value to exactly match the specified enum value. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must be exactly MY_ENUM_VALUE1. + // MyEnum value = 1 [(buf.validate.field).enum.const = 1]; + // } + // ``` + optional int32 const = 1 [(predefined).cel = { + id: "enum.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + + // `defined_only` requires the field value to be one of the defined values for + // this enum, failing on any undefined value. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must be a defined value of MyEnum. + // MyEnum value = 1 [(buf.validate.field).enum.defined_only = true]; + // } + // ``` + optional bool defined_only = 2; + + // `in` requires the field value to be equal to one of the + //specified enum values. If the field value doesn't match any of the + //specified values, an error message is generated. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must be equal to one of the specified values. + // MyEnum value = 1 [(buf.validate.field).enum = { in: [1, 2]}]; + // } + // ``` + repeated int32 in = 3 [(predefined).cel = { + id: "enum.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to be not equal to any of the + //specified enum values. If the field value matches one of the specified + // values, an error message is generated. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must not be equal to any of the specified values. + // MyEnum value = 1 [(buf.validate.field).enum = { not_in: [1, 2]}]; + // } + // ``` + repeated int32 not_in = 4 [(predefined).cel = { + id: "enum.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // (buf.validate.field).enum.example = 1, + // (buf.validate.field).enum.example = 2 + // } + // ``` + repeated int32 example = 5 [(predefined).cel = { + id: "enum.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// RepeatedRules describe the rules applied to `repeated` values. +message RepeatedRules { + // `min_items` requires that this field must contain at least the specified + // minimum number of items. + // + // Note that `min_items = 1` is equivalent to setting a field as `required`. + // + // ```proto + // message MyRepeated { + // // value must contain at least 2 items + // repeated string value = 1 [(buf.validate.field).repeated.min_items = 2]; + // } + // ``` + optional uint64 min_items = 1 [(predefined).cel = { + id: "repeated.min_items" + expression: "uint(this.size()) < rules.min_items ? 'value must contain at least %d item(s)'.format([rules.min_items]) : ''" + }]; + + // `max_items` denotes that this field must not exceed a + // certain number of items as the upper limit. If the field contains more + // items than specified, an error message will be generated, requiring the + // field to maintain no more than the specified number of items. + // + // ```proto + // message MyRepeated { + // // value must contain no more than 3 item(s) + // repeated string value = 1 [(buf.validate.field).repeated.max_items = 3]; + // } + // ``` + optional uint64 max_items = 2 [(predefined).cel = { + id: "repeated.max_items" + expression: "uint(this.size()) > rules.max_items ? 'value must contain no more than %s item(s)'.format([rules.max_items]) : ''" + }]; + + // `unique` indicates that all elements in this field must + // be unique. This rule is strictly applicable to scalar and enum + // types, with message types not being supported. + // + // ```proto + // message MyRepeated { + // // repeated value must contain unique items + // repeated string value = 1 [(buf.validate.field).repeated.unique = true]; + // } + // ``` + optional bool unique = 3 [(predefined).cel = { + id: "repeated.unique" + message: "repeated value must contain unique items" + expression: "!rules.unique || this.unique()" + }]; + + // `items` details the rules to be applied to each item + // in the field. Even for repeated message fields, validation is executed + // against each item unless `ignore` is specified. + // + // ```proto + // message MyRepeated { + // // The items in the field `value` must follow the specified rules. + // repeated string value = 1 [(buf.validate.field).repeated.items = { + // string: { + // min_len: 3 + // max_len: 10 + // } + // }]; + // } + // ``` + // + // Note that the `required` rule does not apply. Repeated items + // cannot be unset. + optional FieldRules items = 4; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// MapRules describe the rules applied to `map` values. +message MapRules { + // Specifies the minimum number of key-value pairs allowed. If the field has + // fewer key-value pairs than specified, an error message is generated. + // + // ```proto + // message MyMap { + // // The field `value` must have at least 2 key-value pairs. + // map value = 1 [(buf.validate.field).map.min_pairs = 2]; + // } + // ``` + optional uint64 min_pairs = 1 [(predefined).cel = { + id: "map.min_pairs" + expression: "uint(this.size()) < rules.min_pairs ? 'map must be at least %d entries'.format([rules.min_pairs]) : ''" + }]; + + // Specifies the maximum number of key-value pairs allowed. If the field has + // more key-value pairs than specified, an error message is generated. + // + // ```proto + // message MyMap { + // // The field `value` must have at most 3 key-value pairs. + // map value = 1 [(buf.validate.field).map.max_pairs = 3]; + // } + // ``` + optional uint64 max_pairs = 2 [(predefined).cel = { + id: "map.max_pairs" + expression: "uint(this.size()) > rules.max_pairs ? 'map must be at most %d entries'.format([rules.max_pairs]) : ''" + }]; + + // Specifies the rules to be applied to each key in the field. + // + // ```proto + // message MyMap { + // // The keys in the field `value` must follow the specified rules. + // map value = 1 [(buf.validate.field).map.keys = { + // string: { + // min_len: 3 + // max_len: 10 + // } + // }]; + // } + // ``` + // + // Note that the `required` rule does not apply. Map keys cannot be unset. + optional FieldRules keys = 4; + + // Specifies the rules to be applied to the value of each key in the + // field. Message values will still have their validations evaluated unless + // `ignore` is specified. + // + // ```proto + // message MyMap { + // // The values in the field `value` must follow the specified rules. + // map value = 1 [(buf.validate.field).map.values = { + // string: { + // min_len: 5 + // max_len: 20 + // } + // }]; + // } + // ``` + // Note that the `required` rule does not apply. Map values cannot be unset. + optional FieldRules values = 5; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// AnyRules describe rules applied exclusively to the `google.protobuf.Any` well-known type. +message AnyRules { + // `in` requires the field's `type_url` to be equal to one of the + //specified values. If it doesn't match any of the specified values, an error + // message is generated. + // + // ```proto + // message MyAny { + // // The `value` field must have a `type_url` equal to one of the specified values. + // google.protobuf.Any value = 1 [(buf.validate.field).any = { + // in: ["type.googleapis.com/MyType1", "type.googleapis.com/MyType2"] + // }]; + // } + // ``` + repeated string in = 2; + + // requires the field's type_url to be not equal to any of the specified values. If it matches any of the specified values, an error message is generated. + // + // ```proto + // message MyAny { + // // The `value` field must not have a `type_url` equal to any of the specified values. + // google.protobuf.Any value = 1 [(buf.validate.field).any = { + // not_in: ["type.googleapis.com/ForbiddenType1", "type.googleapis.com/ForbiddenType2"] + // }]; + // } + // ``` + repeated string not_in = 3; +} + +// DurationRules describe the rules applied exclusively to the `google.protobuf.Duration` well-known type. +message DurationRules { + // `const` dictates that the field must match the specified value of the `google.protobuf.Duration` type exactly. + // If the field's value deviates from the specified value, an error message + // will be generated. + // + // ```proto + // message MyDuration { + // // value must equal 5s + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.const = "5s"]; + // } + // ``` + optional google.protobuf.Duration const = 2 [(predefined).cel = { + id: "duration.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` stipulates that the field must be less than the specified value of the `google.protobuf.Duration` type, + // exclusive. If the field's value is greater than or equal to the specified + // value, an error message will be generated. + // + // ```proto + // message MyDuration { + // // value must be less than 5s + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = "5s"]; + // } + // ``` + google.protobuf.Duration lt = 3 [(predefined).cel = { + id: "duration.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` indicates that the field must be less than or equal to the specified + // value of the `google.protobuf.Duration` type, inclusive. If the field's value is greater than the specified value, + // an error message will be generated. + // + // ```proto + // message MyDuration { + // // value must be less than or equal to 10s + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lte = "10s"]; + // } + // ``` + google.protobuf.Duration lte = 4 [(predefined).cel = { + id: "duration.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the duration field value to be greater than the specified + // value (exclusive). If the value of `gt` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyDuration { + // // duration must be greater than 5s [duration.gt] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gt = { seconds: 5 }]; + // + // // duration must be greater than 5s and less than 10s [duration.gt_lt] + // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gt: { seconds: 5 }, lt: { seconds: 10 } }]; + // + // // duration must be greater than 10s or less than 5s [duration.gt_lt_exclusive] + // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gt: { seconds: 10 }, lt: { seconds: 5 } }]; + // } + // ``` + google.protobuf.Duration gt = 5 [ + (predefined).cel = { + id: "duration.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the duration field value to be greater than or equal to the + // specified value (exclusive). If the value of `gte` is larger than a + // specified `lt` or `lte`, the range is reversed, and the field value must + // be outside the specified range. If the field value doesn't meet the + // required conditions, an error message is generated. + // + // ```proto + // message MyDuration { + // // duration must be greater than or equal to 5s [duration.gte] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gte = { seconds: 5 }]; + // + // // duration must be greater than or equal to 5s and less than 10s [duration.gte_lt] + // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gte: { seconds: 5 }, lt: { seconds: 10 } }]; + // + // // duration must be greater than or equal to 10s or less than 5s [duration.gte_lt_exclusive] + // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gte: { seconds: 10 }, lt: { seconds: 5 } }]; + // } + // ``` + google.protobuf.Duration gte = 6 [ + (predefined).cel = { + id: "duration.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` asserts that the field must be equal to one of the specified values of the `google.protobuf.Duration` type. + // If the field's value doesn't correspond to any of the specified values, + // an error message will be generated. + // + // ```proto + // message MyDuration { + // // value must be in list [1s, 2s, 3s] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.in = ["1s", "2s", "3s"]]; + // } + // ``` + repeated google.protobuf.Duration in = 7 [(predefined).cel = { + id: "duration.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` denotes that the field must not be equal to + // any of the specified values of the `google.protobuf.Duration` type. + // If the field's value matches any of these values, an error message will be + // generated. + // + // ```proto + // message MyDuration { + // // value must not be in list [1s, 2s, 3s] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.not_in = ["1s", "2s", "3s"]]; + // } + // ``` + repeated google.protobuf.Duration not_in = 8 [(predefined).cel = { + id: "duration.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyDuration { + // google.protobuf.Duration value = 1 [ + // (buf.validate.field).duration.example = { seconds: 1 }, + // (buf.validate.field).duration.example = { seconds: 2 }, + // ]; + // } + // ``` + repeated google.protobuf.Duration example = 9 [(predefined).cel = { + id: "duration.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// FieldMaskRules describe rules applied exclusively to the `google.protobuf.FieldMask` well-known type. +message FieldMaskRules { + // `const` dictates that the field must match the specified value of the `google.protobuf.FieldMask` type exactly. + // If the field's value deviates from the specified value, an error message + // will be generated. + // + // ```proto + // message MyFieldMask { + // // value must equal ["a"] + // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask.const = { + // paths: ["a"] + // }]; + // } + // ``` + optional google.protobuf.FieldMask const = 1 [(predefined).cel = { + id: "field_mask.const" + expression: "this.paths != getField(rules, 'const').paths ? 'value must equal paths %s'.format([getField(rules, 'const').paths]) : ''" + }]; + + // `in` requires the field value to only contain paths matching specified + // values or their subpaths. + // If any of the field value's paths doesn't match the rule, + // an error message is generated. + // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask + // + // ```proto + // message MyFieldMask { + // // The `value` FieldMask must only contain paths listed in `in`. + // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = { + // in: ["a", "b", "c.a"] + // }]; + // } + // ``` + repeated string in = 2 [(predefined).cel = { + id: "field_mask.in" + expression: "!this.paths.all(p, p in getField(rules, 'in') || getField(rules, 'in').exists(f, p.startsWith(f+'.'))) ? 'value must only contain paths in %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not contain paths matching specified + // values or their subpaths. + // If any of the field value's paths matches the rule, + // an error message is generated. + // See: https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask + // + // ```proto + // message MyFieldMask { + // // The `value` FieldMask shall not contain paths listed in `not_in`. + // google.protobuf.FieldMask value = 1 [(buf.validate.field).field_mask = { + // not_in: ["forbidden", "immutable", "c.a"] + // }]; + // } + // ``` + repeated string not_in = 3 [(predefined).cel = { + id: "field_mask.not_in" + expression: "!this.paths.all(p, !(p in getField(rules, 'not_in') || getField(rules, 'not_in').exists(f, p.startsWith(f+'.')))) ? 'value must not contain any paths in %s'.format([getField(rules, 'not_in')]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFieldMask { + // google.protobuf.FieldMask value = 1 [ + // (buf.validate.field).field_mask.example = { paths: ["a", "b"] }, + // (buf.validate.field).field_mask.example = { paths: ["c.a", "d"] }, + // ]; + // } + // ``` + repeated google.protobuf.FieldMask example = 4 [(predefined).cel = { + id: "field_mask.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// TimestampRules describe the rules applied exclusively to the `google.protobuf.Timestamp` well-known type. +message TimestampRules { + // `const` dictates that this field, of the `google.protobuf.Timestamp` type, must exactly match the specified value. If the field value doesn't correspond to the specified timestamp, an error message will be generated. + // + // ```proto + // message MyTimestamp { + // // value must equal 2023-05-03T10:00:00Z + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.const = {seconds: 1727998800}]; + // } + // ``` + optional google.protobuf.Timestamp const = 2 [(predefined).cel = { + id: "timestamp.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // requires the duration field value to be less than the specified value (field < value). If the field value doesn't meet the required conditions, an error message is generated. + // + // ```proto + // message MyDuration { + // // duration must be less than 'P3D' [duration.lt] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = { seconds: 259200 }]; + // } + // ``` + google.protobuf.Timestamp lt = 3 [(predefined).cel = { + id: "timestamp.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // requires the timestamp field value to be less than or equal to the specified value (field <= value). If the field value doesn't meet the required conditions, an error message is generated. + // + // ```proto + // message MyTimestamp { + // // timestamp must be less than or equal to '2023-05-14T00:00:00Z' [timestamp.lte] + // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lte = { seconds: 1678867200 }]; + // } + // ``` + google.protobuf.Timestamp lte = 4 [(predefined).cel = { + id: "timestamp.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + + // `lt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be less than the current time. `lt_now` can only be used with the `within` rule. + // + // ```proto + // message MyTimestamp { + // // value must be less than now + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.lt_now = true]; + // } + // ``` + bool lt_now = 7 [(predefined).cel = { + id: "timestamp.lt_now" + expression: "(rules.lt_now && this > now) ? 'value must be less than now' : ''" + }]; + } + oneof greater_than { + // `gt` requires the timestamp field value to be greater than the specified + // value (exclusive). If the value of `gt` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyTimestamp { + // // timestamp must be greater than '2023-01-01T00:00:00Z' [timestamp.gt] + // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gt = { seconds: 1672444800 }]; + // + // // timestamp must be greater than '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gt_lt] + // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gt: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }]; + // + // // timestamp must be greater than '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gt_lt_exclusive] + // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gt: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }]; + // } + // ``` + google.protobuf.Timestamp gt = 5 [ + (predefined).cel = { + id: "timestamp.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the timestamp field value to be greater than or equal to the + // specified value (exclusive). If the value of `gte` is larger than a + // specified `lt` or `lte`, the range is reversed, and the field value + // must be outside the specified range. If the field value doesn't meet + // the required conditions, an error message is generated. + // + // ```proto + // message MyTimestamp { + // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' [timestamp.gte] + // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gte = { seconds: 1672444800 }]; + // + // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gte_lt] + // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gte: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }]; + // + // // timestamp must be greater than or equal to '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gte_lt_exclusive] + // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gte: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }]; + // } + // ``` + google.protobuf.Timestamp gte = 6 [ + (predefined).cel = { + id: "timestamp.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + + // `gt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be greater than the current time. `gt_now` can only be used with the `within` rule. + // + // ```proto + // message MyTimestamp { + // // value must be greater than now + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.gt_now = true]; + // } + // ``` + bool gt_now = 8 [(predefined).cel = { + id: "timestamp.gt_now" + expression: "(rules.gt_now && this < now) ? 'value must be greater than now' : ''" + }]; + } + + // `within` specifies that this field, of the `google.protobuf.Timestamp` type, must be within the specified duration of the current time. If the field value isn't within the duration, an error message is generated. + // + // ```proto + // message MyTimestamp { + // // value must be within 1 hour of now + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.within = {seconds: 3600}]; + // } + // ``` + optional google.protobuf.Duration within = 9 [(predefined).cel = { + id: "timestamp.within" + expression: "this < now-rules.within || this > now+rules.within ? 'value must be within %s of now'.format([rules.within]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyTimestamp { + // google.protobuf.Timestamp value = 1 [ + // (buf.validate.field).timestamp.example = { seconds: 1672444800 }, + // (buf.validate.field).timestamp.example = { seconds: 1672531200 }, + // ]; + // } + // ``` + repeated google.protobuf.Timestamp example = 10 [(predefined).cel = { + id: "timestamp.example" + expression: "true" + }]; + + // Extension fields that have the (buf.validate.predefined) option set + // will be treated as predefined field rules. + // See https://protovalidate.com/schemas/predefined-rules/ + extensions 1000 to max; +} + +// `Violations` is a collection of `Violation` messages. This message type is returned by +// Protovalidate when a proto message fails to meet the requirements set by the `Rule` validation rules. +// Each individual violation is represented by a `Violation` message. +message Violations { + // `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected. + repeated Violation violations = 1; +} + +// `Violation` represents a single instance where a validation rule, expressed +// as a `Rule`, was not met. It provides information about the field that +// caused the violation, the specific rule that wasn't fulfilled, and a +// human-readable error message. +// +// For example, consider the following message: +// +// ```proto +// message User { +// int32 age = 1 [(buf.validate.field).cel = { +// id: "user.age", +// expression: "this < 18 ? 'User must be at least 18 years old' : ''", +// }]; +// } +// ``` +// +// It could produce the following violation: +// +// ```json +// { +// "ruleId": "user.age", +// "message": "User must be at least 18 years old", +// "field": { +// "elements": [ +// { +// "fieldNumber": 1, +// "fieldName": "age", +// "fieldType": "TYPE_INT32" +// } +// ] +// }, +// "rule": { +// "elements": [ +// { +// "fieldNumber": 23, +// "fieldName": "cel", +// "fieldType": "TYPE_MESSAGE", +// "index": "0" +// } +// ] +// } +// } +// ``` +message Violation { + // `field` is a machine-readable path to the field that failed validation. + // This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation. + // + // For example, consider the following message: + // + // ```proto + // message Message { + // bool a = 1 [(buf.validate.field).required = true]; + // } + // ``` + // + // It could produce the following violation: + // + // ```textproto + // violation { + // field { element { field_number: 1, field_name: "a", field_type: 8 } } + // ... + // } + // ``` + optional FieldPath field = 5; + + // `rule` is a machine-readable path that points to the specific rule that failed validation. + // This will be a nested field starting from the FieldRules of the field that failed validation. + // For custom rules, this will provide the path of the rule, e.g. `cel[0]`. + // + // For example, consider the following message: + // + // ```proto + // message Message { + // bool a = 1 [(buf.validate.field).required = true]; + // bool b = 2 [(buf.validate.field).cel = { + // id: "custom_rule", + // expression: "!this ? 'b must be true': ''" + // }] + // } + // ``` + // + // It could produce the following violations: + // + // ```textproto + // violation { + // rule { element { field_number: 25, field_name: "required", field_type: 8 } } + // ... + // } + // violation { + // rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } } + // ... + // } + // ``` + optional FieldPath rule = 6; + + // `rule_id` is the unique identifier of the `Rule` that was not fulfilled. + // This is the same `id` that was specified in the `Rule` message, allowing easy tracing of which rule was violated. + optional string rule_id = 2; + + // `message` is a human-readable error message that describes the nature of the violation. + // This can be the default error message from the violated `Rule`, or it can be a custom message that gives more context about the violation. + optional string message = 3; + + // `for_key` indicates whether the violation was caused by a map key, rather than a value. + optional bool for_key = 4; + + reserved 1; + reserved "field_path"; +} + +// `FieldPath` provides a path to a nested protobuf field. +// +// This message provides enough information to render a dotted field path even without protobuf descriptors. +// It also provides enough information to resolve a nested field through unknown wire data. +message FieldPath { + // `elements` contains each element of the path, starting from the root and recursing downward. + repeated FieldPathElement elements = 1; +} + +// `FieldPathElement` provides enough information to nest through a single protobuf field. +// +// If the selected field is a map or repeated field, the `subscript` value selects a specific element from it. +// A path that refers to a value nested under a map key or repeated field index will have a `subscript` value. +// The `field_type` field allows unambiguous resolution of a field even if descriptors are not available. +message FieldPathElement { + // `field_number` is the field number this path element refers to. + optional int32 field_number = 1; + + // `field_name` contains the field name this path element refers to. + // This can be used to display a human-readable path even if the field number is unknown. + optional string field_name = 2; + + // `field_type` specifies the type of this field. When using reflection, this value is not needed. + // + // This value is provided to make it possible to traverse unknown fields through wire data. + // When traversing wire data, be mindful of both packed[1] and delimited[2] encoding schemes. + // + // [1]: https://protobuf.dev/programming-guides/encoding/#packed + // [2]: https://protobuf.dev/programming-guides/encoding/#groups + // + // N.B.: Although groups are deprecated, the corresponding delimited encoding scheme is not, and + // can be explicitly used in Protocol Buffers 2023 Edition. + optional google.protobuf.FieldDescriptorProto.Type field_type = 3; + + // `key_type` specifies the map key type of this field. This value is useful when traversing + // unknown fields through wire data: specifically, it allows handling the differences between + // different integer encodings. + optional google.protobuf.FieldDescriptorProto.Type key_type = 4; + + // `value_type` specifies map value type of this field. This is useful if you want to display a + // value inside unknown fields through wire data. + optional google.protobuf.FieldDescriptorProto.Type value_type = 5; + + // `subscript` contains a repeated index or map key, if this path element nests into a repeated or map field. + oneof subscript { + // `index` specifies a 0-based index into a repeated field. + uint64 index = 6; + + // `bool_key` specifies a map key of type bool. + bool bool_key = 7; + + // `int_key` specifies a map key of type int32, int64, sint32, sint64, sfixed32 or sfixed64. + int64 int_key = 8; + + // `uint_key` specifies a map key of type uint32, uint64, fixed32 or fixed64. + uint64 uint_key = 9; + + // `string_key` specifies a map key of type string. + string string_key = 10; + } +} diff --git a/internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto b/internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto new file mode 100644 index 00000000..5d7b3ebc --- /dev/null +++ b/internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto @@ -0,0 +1,450 @@ +// Protoconf - Tableau's data interchange format +// https://tableauio.github.io/ + +syntax = "proto3"; + +package tableau; + +import "google/protobuf/descriptor.proto"; + +option go_package = "github.com/tableauio/tableau/proto/tableaupb"; +option java_package = "com.tableau.protobuf"; +option java_outer_classname = "TableauProto"; +option java_multiple_files = true; +option objc_class_prefix = "TPB"; +option csharp_namespace = "Tableau.Protobuf.Tableau"; + +// Option field numbers must be in the range 50000-99999. This range +// is reserved for internal use within individual organizations. + +extend google.protobuf.FileOptions { + WorkbookOptions workbook = 50000; +} + +extend google.protobuf.MessageOptions { + WorksheetOptions worksheet = 50000; + StructOptions struct = 50001; + UnionOptions union = 50002; +} + +extend google.protobuf.FieldOptions { + FieldOptions field = 50000; +} + +extend google.protobuf.EnumOptions { + EnumOptions etype = 50000; +} + +extend google.protobuf.EnumValueOptions { + EnumValueOptions evalue = 50000; +} + +extend google.protobuf.OneofOptions { + optional OneofOptions oneof = 50000; +} + +message EnumOptions { + string name = 1; // Worksheet name. + string note = 2; // Enum type note. Maybe in another language (Chinese). +} + +message EnumValueOptions { + string name = 1; // Enum value alias. + string note = 2; // Enum value note. Maybe in another language (Chinese). +} + +message StructOptions { + string name = 1; // Worksheet name. + string note = 2; // Struct type note. Maybe in another language (Chinese). +} + +message UnionOptions { + string name = 1; // Worksheet name. + string note = 2; // Oneof note, maybe in another language (Chinese). +} + +message OneofOptions { + string name = 1; // Oneof alias. NOT USED yet. + string note = 2; // Oneof note, maybe in another language (Chinese). + string field = 3; // Field name. +} + +message WorkbookOptions { + // filename with path, e.g.: "relative/path/BookName.suffix" (slash path) + string name = 1; + // book alias without suffix, e.g.: "BookAlias" + string alias = 2; + // Exact row number of column name definition at a worksheet. + // + // Default: 1. + int32 namerow = 3; + // Exact row number of column type definition at a worksheet. + // + // Default: 2. + int32 typerow = 4; + // Exact row number of column note definition at a worksheet. + // + // Default: 3. + int32 noterow = 5; + // Start row number of data at a worksheet. + // + // Default: 4. + int32 datarow = 6; + // The line number of column name definition in a cell. 0 means + // the whole cell. + // + // Default: 0. + int32 nameline = 7; + // The line number of column type definition in a cell. 0 means + // the whole cell. + // + // Default: 0. + int32 typeline = 8; + // The line number of column note definition in a cell. 0 means + // the whole cell. + // + // Default: 0. + int32 noteline = 9; + // Sheet-level separator for separating: + // - incell list elements (scalar or struct). + // - incell map items. + // + // If set, it will overwrite global-level seq in options.ConfInputOption.Sep. + string sep = 10; + // Sheet-level subseparator for separating: + // - key-value pair of each incell map item. + // - struct fields of each incell struct list element. + // + // If set, it will overwrite global-level subseq in options.ConfInputOption.Subsep. + string subsep = 11; +} + +message WorksheetOptions { + // Worksheet name + string name = 1; + // Exact row number of column name definition at a worksheet. + // + // Default: 1. + int32 namerow = 2; + // Exact row number of column type definition at a worksheet. + // + // Default: 2. + int32 typerow = 3; + // Exact row number of column note definition at a worksheet. + // + // Default: 3. + int32 noterow = 4; + // Start row number of data at a worksheet. + // + // Default: 4. + int32 datarow = 5; + // The line number of column name definition in a cell. 0 means + // the whole cell. + // + // Default: 0. + int32 nameline = 6; + // The line number of column type definition in a cell. 0 means + // the whole cell. + // + // Default: 0. + int32 typeline = 7; + // The line number of column note definition in a cell. 0 means + // the whole cell. + // + // Default: 0. + int32 noteline = 8; + // Sheet-level separator for separating: + // - incell list elements (scalar or struct). + // - incell map items. + // + // If set, it will overwrite global-level seq in options.ConfInputOption.Sep. + string sep = 9; + // Sheet-level subseparator for separating: + // - key-value pair of each incell map item. + // - struct fields of each incell struct list element. + // + // If set, it will overwrite global-level subseq in options.ConfInputOption.Subsep. + string subsep = 10; + // Nested naming of the namerow. + bool nested = 11; + // Interchange the rows and columns of worksheet. + bool transpose = 12; + // Labels are key/value pairs that are attached to sheet. + // Labels can be used to organize and to select subsets of sheets. + // For example: + // - "app:gamesvr,patch:merge" indicates app is gamesvr and patch is true. + // - "app:*" indicates all apps. + // + // This concept is much like it is in k8s, see + // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/. + map labels = 13; + // Merger merge multiple workbook sheets (comma-separated) into one + // with same schema. E.g.: Item1.xlsx,Item2.xlsx,ItemAward*.xlsx. + repeated string merger = 14; + // Merge adjacent rows with the same key. If the key cell is not set, + // it will be treated the same as the nearest key above the same column. + bool adjacent_key = 15; + // In order to track field presence of basic types (numeric, string, bytes, + // and enums), the generated field will be labeled "optional". + // + // See https://protobuf.dev/programming-guides/field_presence/ + bool field_presence = 16; + // Indicate this XML sheet is a template or not. Template sheet structure will + // only be parsed based on metasheet "@TABLEAU" in comments. + bool template = 17; + // Sheet mode. + Mode mode = 18; + // Scatter convert multiple workbook sheets (comma-separated) separately + // with same schema. E.g.: Item1.xlsx,Item2.xlsx,ItemAward*.xlsx. + repeated string scatter = 19; + // Whether all fields in this sheet are optional (field name existence). + // If set to true, then: + // - table formats (Excel/CSV): field's column can be absent. + // - document formats (XML/YAML): field's name can be absent. + bool optional = 20; + // Sheet patch type. + Patch patch = 21; + // confgen: export JSON/Bin/Text files with parent dir created. + bool with_parent_dir = 22; + // confgen(scatter): export JSON/Bin/Text filenames without book name prefix. + bool scatter_without_book_name = 23; + // Protovalidate message-level rules. The value is a text-format + // representation of buf.validate.MessageRules, e.g.: "cel_expression:\"this.item_map.size() > 0\"". + // + // See https://github.com/bufbuild/protovalidate. + string validate = 24; + + ////////// Loader related options below ////////// + // Generate OrderedMap accessers or not. + bool ordered_map = 50; + // Generate index accessers, and multiple index columns are comma-separated. + // + // Single-column index + // + // Form: Column[@IndexName] + // + // If IndexName is not set, it will be this column’s parent struct type name. + // The columns in the angle brackets `<>` specify the sorting columns, which + // the result array of same index key sort by. + // + // Multi-column index + // + // Form: (Column1,Column2,...)[@IndexName] + // + // Examples: + // - ID + // - ID@Item + // - (ID,Type) + // - (ID,Type)@Item + // - (ID,Type)@Item + // - (ID,Type)@Item + // - ID, (ID,Type)@Item + repeated string index = 51; + + // Specify loader language options. + // Valid keys are: OrderedMap, Index, OrderedIndex. + // Different kvs must be seperated by ',' and one key value must be seperated + // by ':'. If one key doesn't exist in map, it means that this loader option + // is supported in all languages. Valid values are all combinations of "cpp", + // "go" and "csharp" with ' ' as seperator. + // + // Examples: + // - OrderedMap:cpp,Index:cpp go // ordered map supported in cpp, index + // supported in cpp and go + // - OrderedMap:cpp // ordered map supported in cpp, index supported in all + // languages + map lang_options = 52; + + // Generate OrderedIndex accessers, and multiple index columns are comma-separated. + // Formats are same with index. + repeated string ordered_index = 53; +} + +message FieldOptions { + string name = 1; // Scalar type's variable name or composite type's variable name (prefix). + string note = 2; // Field note. Maybe in another language (Chinese). + string key = 3; // Only set when this field type is map or keyed-list. + Layout layout = 4; // For map/list types with cardinality. Default: LAYOUT_DEFAULT. + Span span = 5; // For list element or map value types. Default: SPAN_CROSS_CELL. + + FieldProp prop = 15; // Property of field. +} + +message FieldProp { + // Usage: {range:"1,10" refer:"Item.ID"} + + // Different interpretations of range: + // - number: value range + // - string: count of utf-8 code point + // + // Format: "1,10", "1,~", "~,10". + string range = 1; + // Whether the map key is unique in column. + // If not set, then auto deduce whether the map key is unique or not. + optional bool unique = 2; + // Ensure this field's value is in another sheet's + // column value space (aka message's field value space). + // + // Format: "SheetName.ColumnName" or "SheetName(SheetAlias).ColumnName" + // + // Example: + // - "SheetName.ColumnName": e.g. "Item.ID", without sheet alias, and + // the sheet name is the generated protobuf message name. + // - "SheetName(SheetAlias).ColumnName": e.g. "Item(ItemConf).ID", with + // sheet alias, and sheet alias is the generated protobuf message name. + string refer = 3; + // Ensure this field's value is a sequence and begins with this value. + // Mainly used for map key and list element. + optional int64 sequence = 4; + // Specify custom default value of scalar field. + string default = 5; + // Auto detect fixed size of horizontal list or map. + // - list size is detected by size of the max present list elements in name row. + // - map size is detected by size of the max present map items in name row. + bool fixed = 6; + // Specify fixed size of horizontal list or map. + uint32 size = 7; + // Specify cell data form for parsing. + Form form = 8; + // JSON name of this field. The value is set by protocol compiler. If the + // user has set a "json_name" option on this field, that option's value + // will be used. Otherwise, it's deduced from the field's name by converting + // it to camelCase. + string json_name = 9; + // Whether this field value is present (field value existence). + // If set to true, then do the following checks for different field types: + // - scalar/enum: cell data cannot be empty string (TODO: If this field's + // type is string, then how to set empty string explicitly?) + // - struct: check at least one field is present recursively + // - map/list: len(elements) > 0 + bool present = 10; + // Whether this field is optional (field name existence). + // If set to true, then: + // - table formats (Excel/CSV): field's column can be absent. + // - document formats (XML/YAML): field's name can be absent. + bool optional = 11; + // Field patch type. + Patch patch = 12; + // Field-level separator for separating: + // - incell list elements (scalar or struct). + // - incell map items. + // + // If set, it will overwrite sheet-level seq in WorksheetOptions. + string sep = 13; + // Field-level subseparator for separating: + // - key-value pair of each incell map item. + // - struct fields of each incell struct list element. + // + // If set, it will overwrite sheet-level subseq in WorksheetOptions. + string subsep = 14; + // NOTE: field number 15 (cross) is reserved for backward compatibility. + reserved 15; + // Specify the pattern of scalar, list element, and map value. + // + // For version (tableau.Version) field: + // + // Specify the dotted-decimal pattern of current cell. Each decimal + // number ranges from 0 to the corresponding part (MAX) of pattern. + // Default pattern: "255.255.255". + // + // TODO: use cases for more field types. + string pattern = 16; + // Ensure this field's value is in order. + Order order = 17; + // Protovalidate field-level rules of scalar and well-known types. The value is + // a text-format representation of buf.validate.FieldRules, e.g.: "string:{max_len:10}". + // + // See https://github.com/bufbuild/protovalidate. + string validate = 18; + // Protovalidate field-level rules of complex types: list, map. The value is a text-format + // representation of buf.validate.FieldRules, e.g.: "repeated:{min_items:1}". + // + // See https://github.com/bufbuild/protovalidate. + string validate_complex = 19; + // Protovalidate message-level rules for the nested message corresponding to + // this field. The value is a text-format representation of buf.validate.MessageRules, + // e.g.: cel_expression:"this.begin > this.end ? 'begin(%s) must <= end(%s)'.format([this.begin, this.end]): ''". + // + // See https://github.com/bufbuild/protovalidate. + string validate_message = 20; +} + +// Layout of list and map. +enum Layout { + // Default: + // - vertical for struct map + // - incell for scalar map + // - horizontal for struct list + // - incell for scalar list + LAYOUT_DEFAULT = 0; + LAYOUT_VERTICAL = 1; // Vertical + LAYOUT_HORIZONTAL = 2; // Horizontal + LAYOUT_INCELL = 3; // Incell +} + +// Field data span of scalar and struct. +enum Span { + // Default: + // - inner cell for scalar type: bool, string, bytes, number, and enum. + // - cross cell for struct type: map-value, list-element, and struct-field. + SPAN_DEFAULT = 0; + SPAN_CROSS_CELL = 1; // The field data spans across multiple cells. + SPAN_INNER_CELL = 2; // The field data spans inside one cell. +} + +// Sheet mode. +enum Mode { + MODE_DEFAULT = 0; // Default mode. + MODE_ENUM_TYPE = 1; // Enum type: single definition in a sheet. + MODE_ENUM_TYPE_MULTI = 2; // Enum type: multiple definitions in a sheet. + MODE_STRUCT_TYPE = 3; // Struct type: single definition in a sheet. + MODE_STRUCT_TYPE_MULTI = 4; // Struct type: multiple definitions in a sheet. + MODE_UNION_TYPE = 5; // Union type: single definition in a sheet. + MODE_UNION_TYPE_MULTI = 6; // Union type: multiple definitions in a sheet. + + // UE DataTable references: + // - https://dev.epicgames.com/documentation/en-us/unreal-engine/data-driven-gameplay-elements-in-unreal-engine + // - https://dev.epicgames.com/documentation/en-us/unreal-engine/BlueprintAPI/EditorScripting/DataTable + MODE_UE_CSV = 10; // TODO: CSV format of UE DataTable. + MODE_UE_JSON = 11; // TODO: JSON format of UE DataTable. +} + +// Cell data form. +enum Form { + FORM_DEFAULT = 0; // Default form which confgen parser will parse. + FORM_TEXT = 1; // Refer: https://developers.google.com/protocol-buffers/docs/text-format-spec + FORM_JSON = 2; // Refer: https://developers.google.com/protocol-buffers/docs/proto3#json +} + +// Patch type for both sheet-level and field-level. +enum Patch { + PATCH_NONE = 0; + // 1 Sheet-level patch option "PATCH_REPLACE" + // - replace whole message + // 2 Top-field patch option "PATCH_REPLACE" + // - list: Clear field firstly, and then all elements of this list field + // in src are appended to the corresponded list fields in dst. + // - map: Clear field firstly, and then all entries of this map field in src + // are copied into the corresponding map field in dst. + PATCH_REPLACE = 1; + // Merge src into dst, which must be a message with the same descriptor. + // - scalar: Populated scalar fields in src are copied to dst. + // - message: Populated singular messages in src are merged into dst by + // recursively calling [proto.Merge](https://pkg.go.dev/google.golang.org/protobuf/proto#Merge). + // - list: The elements of every list field in src are appended to the + // corresponded list fields in dst. + // - map: The entries of every map field in src are copied into the + // corresponding map field in dst, possibly replacing existing entries. + // - unknown: The unknown fields of src are appended to the unknown + // fields of dst. + PATCH_MERGE = 2; +} + +// Field value order. +enum Order { + ORDER_NONE = 0; + ORDER_ASC = 1; // ascending: >= + ORDER_DESC = 2; // descending: <= + ORDER_STRICTLY_ASC = 3; // strictly ascending: > + ORDER_STRICTLY_DESC = 4; // strictly descending: < +} \ No newline at end of file diff --git a/internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto b/internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto new file mode 100644 index 00000000..ee37b390 --- /dev/null +++ b/internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto @@ -0,0 +1,115 @@ +// Protoconf - Tableau's data interchange format +// https://tableauio.github.io/ + +syntax = "proto3"; + +package tableau; + +option cc_enable_arenas = true; +option go_package = "github.com/tableauio/tableau/proto/tableaupb"; +option java_package = "com.tableau.protobuf"; +option java_outer_classname = "TableauProto"; +option java_multiple_files = true; +option objc_class_prefix = "TPB"; +option csharp_namespace = "Tableau.Protobuf.Tableau"; + +import "tableau/protobuf/tableau.proto"; + +// Supported formats: +// - N%: percentage, e.g.: 10% +// - N‰: per thounsand, e.g.: 10‰ +// - N‱: per ten thounsand, e.g.: 10‱ +// - N/D: simple fraction, e.g.: 3/4 +// - N: only numerator, e.g.: 3 is same to 3/1 +message Fraction { + int32 num = 1; // numerator + int32 den = 2; // denominator +} + +// Format: +// e.g.: ==10, !=1/2, <10%, <=10‰, >10%, >=10‱ +message Comparator { + Sign sign = 1; + Fraction value = 2; + + enum Sign { + SIGN_EQUAL = 0; // == + SIGN_NOT_EQUAL = 1; // != + SIGN_LESS = 2; // < + SIGN_LESS_OR_EQUAL = 3; // <= + SIGN_GREATER = 4; // > + SIGN_GREATER_OR_EQUAL = 5; // >= + } +} + +// TODO: +// - Vector2d for double 2D vector +// - Vector2l for int64 (long) 2D vector +// ... + +// A 2D vector using float coordinates. +// See https://docs.godotengine.org/en/stable/classes/class_vector2.html +message Vector2 { + float x = 1 [(tableau.field) = { name: "X" }]; + float y = 2 [(tableau.field) = { name: "Y" }]; +} + +// A 3D vector using float coordinates. +// See https://docs.godotengine.org/en/stable/classes/class_vector3.html +message Vector3 { + float x = 1 [(tableau.field) = { name: "X" }]; + float y = 2 [(tableau.field) = { name: "Y" }]; + float z = 3 [(tableau.field) = { name: "Z" }]; +} + +// A 4D vector using float coordinates. +// See https://docs.godotengine.org/en/stable/classes/class_vector4.html +message Vector4 { + float x = 1 [(tableau.field) = { name: "X" }]; + float y = 2 [(tableau.field) = { name: "Y" }]; + float z = 3 [(tableau.field) = { name: "Z" }]; + float w = 4 [(tableau.field) = { name: "W" }]; +} + +// A 2D vector using int32 coordinates. +// See https://docs.godotengine.org/en/stable/classes/class_vector2i.html +message Vector2i { + int32 x = 1 [(tableau.field) = { name: "X" }]; + int32 y = 2 [(tableau.field) = { name: "Y" }]; +} + +// A 3D vector using int32 coordinates. +// See https://docs.godotengine.org/en/stable/classes/class_vector3i.html +message Vector3i { + int32 x = 1 [(tableau.field) = { name: "X" }]; + int32 y = 2 [(tableau.field) = { name: "Y" }]; + int32 z = 3 [(tableau.field) = { name: "Z" }]; +} + +// A 4D vector using int32 coordinates. +// See https://docs.godotengine.org/en/stable/classes/class_vector4i.html +message Vector4i { + int32 x = 1 [(tableau.field) = { name: "X" }]; + int32 y = 2 [(tableau.field) = { name: "Y" }]; + int32 z = 3 [(tableau.field) = { name: "Z" }]; + int32 w = 4 [(tableau.field) = { name: "W" }]; +} + +// Version number in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation). +// The version form is "..[.]...". +// +// You can specify the version pattern as "..[.]...". +// - Each part with suffix "MAX" represents the max decimal value of each part in the dot-decimal notation. +// - Each part "XXX_MAX+1" represents the part's value occupying in an integer. +// - For example, the formula for general pattern ".." is: +// MAJOR*(MINOR_MAX+1)*(PATCH_MAX+1) + MINOR*(PATCH_MAX+1) + PATCH +// +// Default pattern: "255.255.255". +message Version { + string str = 1; // Version in string form. + uint64 val = 2; // Version in integer form. + uint32 major = 3; // Major version number. + uint32 minor = 4; // Minor version number. + uint32 patch = 5; // Patch version number. + repeated uint32 others = 6; // Other version numbers, such as build number, resource version, and so on. +} \ No newline at end of file diff --git a/internal/x/xproto/protoc/gen_embedded.sh b/internal/x/xproto/protoc/gen_embedded.sh new file mode 100755 index 00000000..c2da7ad3 --- /dev/null +++ b/internal/x/xproto/protoc/gen_embedded.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# Refreshes the embedded/ directory consumed by embed.go. +# +# Invoked by `go generate ./...` (see embed.go). Run from the directory +# containing this script (the dir of embed.go); `go generate` guarantees +# that cwd. +# +# Steps: +# 1. Wipe embedded/ to start clean. +# 2. Copy this repository's own proto/tableau/protobuf/*.proto files +# (top-level only — internal/ and unittest/ are intentionally skipped +# to match buf.yaml excludes). +# 3. Read the protovalidate commit pinned in buf.lock and `buf export` +# that exact commit so the vendored copy stays aligned with buf.lock. +# `buf export ` without a commit suffix pulls latest; +# buf.lock only governs intra-workspace resolution, not ad-hoc export. + +set -euo pipefail + +REPO_ROOT="$(git rev-parse --show-toplevel)" +BUF_LOCK="$REPO_ROOT/buf.lock" + +rm -rf embedded +mkdir -p embedded/tableau/protobuf + +cp "$REPO_ROOT"/proto/tableau/protobuf/*.proto embedded/tableau/protobuf/ + +commit=$(awk ' + /name: buf.build\/bufbuild\/protovalidate/ { found = 1 } + found && /commit:/ { print $2; exit } +' "$BUF_LOCK") + +if [ -z "$commit" ]; then + echo "gen_embedded.sh: failed to read protovalidate commit from $BUF_LOCK" >&2 + exit 1 +fi + +buf export "buf.build/bufbuild/protovalidate:$commit" -o embedded From ceddc06829d3ef706573116bb04b99e3327e13bc Mon Sep 17 00:00:00 2001 From: Kybxd <627940450@qq.com> Date: Thu, 14 May 2026 11:06:06 +0800 Subject: [PATCH 2/4] perf: lazily compute proto registry with generated files --- internal/x/xproto/protoc/compiler.go | 74 ++++++++++------------------ 1 file changed, 27 insertions(+), 47 deletions(-) diff --git a/internal/x/xproto/protoc/compiler.go b/internal/x/xproto/protoc/compiler.go index 30dc9d15..27857680 100644 --- a/internal/x/xproto/protoc/compiler.go +++ b/internal/x/xproto/protoc/compiler.go @@ -19,6 +19,7 @@ package protoc import ( "context" + "errors" "fmt" "io/fs" "maps" @@ -96,24 +97,21 @@ func parseProtos(protoPaths []string, protoFilesMap map[string]string) (*protore protoFiles := slices.Collect(maps.Values(protoFilesMap)) - // Build a layered Opener: - // 1. user sources (resolved against protoPaths, gated by protoFilesMap) - // 2. embedded sources (tableau + buf/validate) - // 3. WKTs (google/protobuf/*) - userOpener := &filesystemOpener{importPaths: protoPaths} - embeddedOpener := &fsOpener{fs: embeddedFS(), tag: ""} - combined := &source.Openers{userOpener, embeddedOpener, source.WKTs()} - - workspace := source.NewWorkspace(protoFiles...) - executor := incremental.New(incremental.WithParallelism(1)) - session := new(ir.Session) - query := queries.FDS{ - Opener: combined, - Session: session, - Workspace: workspace, + Opener: &source.Openers{ + // Build a layered Opener: + // 1. user sources (resolved against protoPaths, gated by protoFilesMap) + // 2. embedded sources (tableau + buf/validate) + // 3. WKTs (google/protobuf/*) + &filesystemOpener{importPaths: protoPaths}, + &fsOpener{fs: embeddedFS(), tag: ""}, + source.WKTs(), + }, + Session: new(ir.Session), + Workspace: source.NewWorkspace(protoFiles...), } - results, rpt, err := incremental.Run(context.Background(), executor, query) + + results, rpt, err := incremental.Run(context.Background(), incremental.New(), query) if err != nil { return nil, err } @@ -188,12 +186,6 @@ type filesystemOpener struct { // Open implements [source.Opener]. func (o *filesystemOpener) Open(path string) (*source.File, error) { clean := xfs.CleanSlashPath(path) - if len(o.importPaths) == 0 { - if data, err := os.ReadFile(clean); err == nil { - return source.NewFile(path, string(data)), nil - } - return nil, fs.ErrNotExist - } for _, root := range o.importPaths { full := xfs.CleanSlashPath(filepath.Join(root, clean)) if data, err := os.ReadFile(full); err == nil { @@ -232,43 +224,31 @@ func (o *fsOpener) Open(path string) (*source.File, error) { // // When no source span is available, the line/column components are // omitted. When no file is available, only the message is emitted. -func reportToError(rpt *report.Report) error { - if rpt == nil { +func reportToError(r *report.Report) error { + if r == nil { return nil } - var errs []string - for i := range rpt.Diagnostics { - d := &rpt.Diagnostics[i] - msg := formatDiagnostic(d) - switch d.Level() { - case report.Error, report.ICE: - errs = append(errs, msg) - case report.Warning: - log.Warnf("protocompile: %s", msg) - } + var errs []error + for _, d := range r.Diagnostics { + errs = append(errs, formatDiagnostic(&d)) } if len(errs) == 0 { return nil } - return fmt.Errorf("protocompile: %s", strings.Join(errs, "\n")) + return errors.Join(errs...) } // formatDiagnostic renders a single diagnostic in buf's // ":::" format. Missing components are skipped. -func formatDiagnostic(d *report.Diagnostic) string { - file := d.File() - span := d.Primary() - if !span.IsZero() { +func formatDiagnostic(d *report.Diagnostic) error { + switch d.Level() { + case report.Error, report.ICE: + span := d.Primary() loc := span.StartLoc() - if file != "" { - return fmt.Sprintf("%s:%d:%d:%s", file, loc.Line, loc.Column, d.Message()) - } - return fmt.Sprintf("%d:%d:%s", loc.Line, loc.Column, d.Message()) - } - if file != "" { - return fmt.Sprintf("%s:%s", file, d.Message()) + return fmt.Errorf("%s:%d:%d:%s", span.Path(), loc.Line, loc.Column, d.Message()) + default: + return nil } - return d.Message() } // removeDynamicExtensionsFromProto rewrites *FileDescriptorProto-tree From 7aeb4d5fd546cc1051ec8319af365b23d0c849d5 Mon Sep 17 00:00:00 2001 From: Kybxd <627940450@qq.com> Date: Thu, 9 Jul 2026 15:05:40 +0800 Subject: [PATCH 3/4] chore(protoc): sync embedded proto files via go generate Regenerate embedded/tableau/protobuf/tableau.proto, wellknown.proto and embedded/buf/validate/validate.proto to sync with the aggregate field added to FieldProp in proto/tableau/protobuf/tableau.proto (PR #395). The stale embedded copy caused test/functest failures: "cannot resolve message field name for tableau.FieldProp". --- .../embedded/buf/validate/validate.proto | 951 ++++++++++-------- .../embedded/tableau/protobuf/tableau.proto | 109 +- .../embedded/tableau/protobuf/wellknown.proto | 76 +- 3 files changed, 614 insertions(+), 522 deletions(-) diff --git a/internal/x/xproto/protoc/embedded/buf/validate/validate.proto b/internal/x/xproto/protoc/embedded/buf/validate/validate.proto index f0371d39..56117c88 100644 --- a/internal/x/xproto/protoc/embedded/buf/validate/validate.proto +++ b/internal/x/xproto/protoc/embedded/buf/validate/validate.proto @@ -37,7 +37,7 @@ syntax = "proto2"; // // These rules are enforced at runtime by language-specific libraries. // See the [developer quickstart](https://protovalidate.com/quickstart/) to get started, or go directly to the runtime library for your language: -// [Go](https://github.com/bufbuild/protovalidate-go) +// [Go](https://github.com/bufbuild/protovalidate-go), // [JavaScript/TypeScript](https://github.com/bufbuild/protovalidate-es), // [Java](https://github.com/bufbuild/protovalidate-java), // [Python](https://github.com/bufbuild/protovalidate-python), @@ -90,7 +90,7 @@ extend google.protobuf.FieldOptions { // extend buf.validate.Int32Rules { // bool is_zero [(buf.validate.predefined).cel = { // id: "int32.is_zero", - // message: "value must be zero", + // message: "must be zero", // expression: "!rule || this == 0", // }]; // } @@ -167,7 +167,7 @@ message MessageRules { // // The field `foo` must be greater than 42. // option (buf.validate.message).cel = { // id: "my_message.value", - // message: "value must be greater than 42", + // message: "must be greater than 42", // expression: "this.foo > 42", // }; // optional int32 foo = 1; @@ -274,7 +274,7 @@ message FieldRules { // // The field `value` must be greater than 42. // optional int32 value = 1 [(buf.validate.field).cel = { // id: "my_message.value", - // message: "value must be greater than 42", + // message: "must be greater than 42", // expression: "this > 42", // }]; // } @@ -397,7 +397,7 @@ message PredefinedRules { // // The field `value` must be greater than 42. // optional int32 value = 1 [(buf.validate.predefined).cel = { // id: "my_message.value", - // message: "value must be greater than 42", + // message: "must be greater than 42", // expression: "this > 42", // }]; // } @@ -514,7 +514,7 @@ message FloatRules { // ``` optional float const = 1 [(predefined).cel = { id: "float.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { @@ -524,7 +524,7 @@ message FloatRules { // // ```proto // message MyFloat { - // // value must be less than 10.0 + // // must be less than 10.0 // float value = 1 [(buf.validate.field).float.lt = 10.0]; // } // ``` @@ -532,7 +532,7 @@ message FloatRules { id: "float.lt" expression: "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -541,7 +541,7 @@ message FloatRules { // // ```proto // message MyFloat { - // // value must be less than or equal to 10.0 + // // must be less than or equal to 10.0 // float value = 1 [(buf.validate.field).float.lte = 10.0]; // } // ``` @@ -549,7 +549,7 @@ message FloatRules { id: "float.lte" expression: "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } @@ -562,13 +562,13 @@ message FloatRules { // // ```proto // message MyFloat { - // // value must be greater than 5.0 [float.gt] + // // must be greater than 5.0 [float.gt] // float value = 1 [(buf.validate.field).float.gt = 5.0]; // - // // value must be greater than 5 and less than 10.0 [float.gt_lt] + // // must be greater than 5 and less than 10.0 [float.gt_lt] // float other_value = 2 [(buf.validate.field).float = { gt: 5.0, lt: 10.0 }]; // - // // value must be greater than 10 or less than 5.0 [float.gt_lt_exclusive] + // // must be greater than 10 or less than 5.0 [float.gt_lt_exclusive] // float another_value = 3 [(buf.validate.field).float = { gt: 10.0, lt: 5.0 }]; // } // ``` @@ -577,31 +577,31 @@ message FloatRules { id: "float.gt" expression: "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "float.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "float.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "float.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "float.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -613,13 +613,13 @@ message FloatRules { // // ```proto // message MyFloat { - // // value must be greater than or equal to 5.0 [float.gte] + // // must be greater than or equal to 5.0 [float.gte] // float value = 1 [(buf.validate.field).float.gte = 5.0]; // - // // value must be greater than or equal to 5.0 and less than 10.0 [float.gte_lt] + // // must be greater than or equal to 5.0 and less than 10.0 [float.gte_lt] // float other_value = 2 [(buf.validate.field).float = { gte: 5.0, lt: 10.0 }]; // - // // value must be greater than or equal to 10.0 or less than 5.0 [float.gte_lt_exclusive] + // // must be greater than or equal to 10.0 or less than 5.0 [float.gte_lt_exclusive] // float another_value = 3 [(buf.validate.field).float = { gte: 10.0, lt: 5.0 }]; // } // ``` @@ -628,31 +628,31 @@ message FloatRules { id: "float.gte" expression: "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "float.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "float.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "float.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "float.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -663,16 +663,16 @@ message FloatRules { // // ```proto // message MyFloat { - // // value must be in list [1.0, 2.0, 3.0] + // // must be in list [1.0, 2.0, 3.0] // float value = 1 [(buf.validate.field).float = { in: [1.0, 2.0, 3.0] }]; // } // ``` repeated float in = 6 [(predefined).cel = { id: "float.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; - // `in` requires the field value to not be equal to any of the specified + // `not_in` requires the field value to not be equal to any of the specified // values. If the field value is one of the specified values, an error // message is generated. // @@ -684,14 +684,14 @@ message FloatRules { // ``` repeated float not_in = 7 [(predefined).cel = { id: "float.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `finite` requires the field value to be finite. If the field value is // infinite or NaN, an error message is generated. optional bool finite = 8 [(predefined).cel = { id: "float.finite" - expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" + expression: "rules.finite ? (this.isNan() || this.isInf() ? 'must be finite' : '') : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -731,7 +731,7 @@ message DoubleRules { // ``` optional double const = 1 [(predefined).cel = { id: "double.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -740,7 +740,7 @@ message DoubleRules { // // ```proto // message MyDouble { - // // value must be less than 10.0 + // // must be less than 10.0 // double value = 1 [(buf.validate.field).double.lt = 10.0]; // } // ``` @@ -748,7 +748,7 @@ message DoubleRules { id: "double.lt" expression: "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified value @@ -757,7 +757,7 @@ message DoubleRules { // // ```proto // message MyDouble { - // // value must be less than or equal to 10.0 + // // must be less than or equal to 10.0 // double value = 1 [(buf.validate.field).double.lte = 10.0]; // } // ``` @@ -765,7 +765,7 @@ message DoubleRules { id: "double.lte" expression: "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -777,13 +777,13 @@ message DoubleRules { // // ```proto // message MyDouble { - // // value must be greater than 5.0 [double.gt] + // // must be greater than 5.0 [double.gt] // double value = 1 [(buf.validate.field).double.gt = 5.0]; // - // // value must be greater than 5 and less than 10.0 [double.gt_lt] + // // must be greater than 5 and less than 10.0 [double.gt_lt] // double other_value = 2 [(buf.validate.field).double = { gt: 5.0, lt: 10.0 }]; // - // // value must be greater than 10 or less than 5.0 [double.gt_lt_exclusive] + // // must be greater than 10 or less than 5.0 [double.gt_lt_exclusive] // double another_value = 3 [(buf.validate.field).double = { gt: 10.0, lt: 5.0 }]; // } // ``` @@ -792,31 +792,31 @@ message DoubleRules { id: "double.gt" expression: "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "double.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "double.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "double.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "double.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -828,13 +828,13 @@ message DoubleRules { // // ```proto // message MyDouble { - // // value must be greater than or equal to 5.0 [double.gte] + // // must be greater than or equal to 5.0 [double.gte] // double value = 1 [(buf.validate.field).double.gte = 5.0]; // - // // value must be greater than or equal to 5.0 and less than 10.0 [double.gte_lt] + // // must be greater than or equal to 5.0 and less than 10.0 [double.gte_lt] // double other_value = 2 [(buf.validate.field).double = { gte: 5.0, lt: 10.0 }]; // - // // value must be greater than or equal to 10.0 or less than 5.0 [double.gte_lt_exclusive] + // // must be greater than or equal to 10.0 or less than 5.0 [double.gte_lt_exclusive] // double another_value = 3 [(buf.validate.field).double = { gte: 10.0, lt: 5.0 }]; // } // ``` @@ -843,31 +843,31 @@ message DoubleRules { id: "double.gte" expression: "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "double.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "double.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "double.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "double.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -877,13 +877,13 @@ message DoubleRules { // // ```proto // message MyDouble { - // // value must be in list [1.0, 2.0, 3.0] + // // must be in list [1.0, 2.0, 3.0] // double value = 1 [(buf.validate.field).double = { in: [1.0, 2.0, 3.0] }]; // } // ``` repeated double in = 6 [(predefined).cel = { id: "double.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -898,14 +898,14 @@ message DoubleRules { // ``` repeated double not_in = 7 [(predefined).cel = { id: "double.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `finite` requires the field value to be finite. If the field value is // infinite or NaN, an error message is generated. optional bool finite = 8 [(predefined).cel = { id: "double.finite" - expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" + expression: "rules.finite ? (this.isNan() || this.isInf() ? 'must be finite' : '') : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -945,7 +945,7 @@ message Int32Rules { // ``` optional int32 const = 1 [(predefined).cel = { id: "int32.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field @@ -954,7 +954,7 @@ message Int32Rules { // // ```proto // message MyInt32 { - // // value must be less than 10 + // // must be less than 10 // int32 value = 1 [(buf.validate.field).int32.lt = 10]; // } // ``` @@ -962,7 +962,7 @@ message Int32Rules { id: "int32.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -971,7 +971,7 @@ message Int32Rules { // // ```proto // message MyInt32 { - // // value must be less than or equal to 10 + // // must be less than or equal to 10 // int32 value = 1 [(buf.validate.field).int32.lte = 10]; // } // ``` @@ -979,7 +979,7 @@ message Int32Rules { id: "int32.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -991,13 +991,13 @@ message Int32Rules { // // ```proto // message MyInt32 { - // // value must be greater than 5 [int32.gt] + // // must be greater than 5 [int32.gt] // int32 value = 1 [(buf.validate.field).int32.gt = 5]; // - // // value must be greater than 5 and less than 10 [int32.gt_lt] + // // must be greater than 5 and less than 10 [int32.gt_lt] // int32 other_value = 2 [(buf.validate.field).int32 = { gt: 5, lt: 10 }]; // - // // value must be greater than 10 or less than 5 [int32.gt_lt_exclusive] + // // must be greater than 10 or less than 5 [int32.gt_lt_exclusive] // int32 another_value = 3 [(buf.validate.field).int32 = { gt: 10, lt: 5 }]; // } // ``` @@ -1006,31 +1006,31 @@ message Int32Rules { id: "int32.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "int32.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "int32.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "int32.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "int32.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -1042,13 +1042,13 @@ message Int32Rules { // // ```proto // message MyInt32 { - // // value must be greater than or equal to 5 [int32.gte] + // // must be greater than or equal to 5 [int32.gte] // int32 value = 1 [(buf.validate.field).int32.gte = 5]; // - // // value must be greater than or equal to 5 and less than 10 [int32.gte_lt] + // // must be greater than or equal to 5 and less than 10 [int32.gte_lt] // int32 other_value = 2 [(buf.validate.field).int32 = { gte: 5, lt: 10 }]; // - // // value must be greater than or equal to 10 or less than 5 [int32.gte_lt_exclusive] + // // must be greater than or equal to 10 or less than 5 [int32.gte_lt_exclusive] // int32 another_value = 3 [(buf.validate.field).int32 = { gte: 10, lt: 5 }]; // } // ``` @@ -1057,31 +1057,31 @@ message Int32Rules { id: "int32.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "int32.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "int32.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "int32.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "int32.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -1092,13 +1092,13 @@ message Int32Rules { // // ```proto // message MyInt32 { - // // value must be in list [1, 2, 3] + // // must be in list [1, 2, 3] // int32 value = 1 [(buf.validate.field).int32 = { in: [1, 2, 3] }]; // } // ``` repeated int32 in = 6 [(predefined).cel = { id: "int32.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -1113,7 +1113,7 @@ message Int32Rules { // ``` repeated int32 not_in = 7 [(predefined).cel = { id: "int32.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -1153,7 +1153,7 @@ message Int64Rules { // ``` optional int64 const = 1 [(predefined).cel = { id: "int64.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -1162,7 +1162,7 @@ message Int64Rules { // // ```proto // message MyInt64 { - // // value must be less than 10 + // // must be less than 10 // int64 value = 1 [(buf.validate.field).int64.lt = 10]; // } // ``` @@ -1170,7 +1170,7 @@ message Int64Rules { id: "int64.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -1179,7 +1179,7 @@ message Int64Rules { // // ```proto // message MyInt64 { - // // value must be less than or equal to 10 + // // must be less than or equal to 10 // int64 value = 1 [(buf.validate.field).int64.lte = 10]; // } // ``` @@ -1187,7 +1187,7 @@ message Int64Rules { id: "int64.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -1199,13 +1199,13 @@ message Int64Rules { // // ```proto // message MyInt64 { - // // value must be greater than 5 [int64.gt] + // // must be greater than 5 [int64.gt] // int64 value = 1 [(buf.validate.field).int64.gt = 5]; // - // // value must be greater than 5 and less than 10 [int64.gt_lt] + // // must be greater than 5 and less than 10 [int64.gt_lt] // int64 other_value = 2 [(buf.validate.field).int64 = { gt: 5, lt: 10 }]; // - // // value must be greater than 10 or less than 5 [int64.gt_lt_exclusive] + // // must be greater than 10 or less than 5 [int64.gt_lt_exclusive] // int64 another_value = 3 [(buf.validate.field).int64 = { gt: 10, lt: 5 }]; // } // ``` @@ -1214,31 +1214,31 @@ message Int64Rules { id: "int64.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "int64.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "int64.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "int64.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "int64.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -1250,13 +1250,13 @@ message Int64Rules { // // ```proto // message MyInt64 { - // // value must be greater than or equal to 5 [int64.gte] + // // must be greater than or equal to 5 [int64.gte] // int64 value = 1 [(buf.validate.field).int64.gte = 5]; // - // // value must be greater than or equal to 5 and less than 10 [int64.gte_lt] + // // must be greater than or equal to 5 and less than 10 [int64.gte_lt] // int64 other_value = 2 [(buf.validate.field).int64 = { gte: 5, lt: 10 }]; // - // // value must be greater than or equal to 10 or less than 5 [int64.gte_lt_exclusive] + // // must be greater than or equal to 10 or less than 5 [int64.gte_lt_exclusive] // int64 another_value = 3 [(buf.validate.field).int64 = { gte: 10, lt: 5 }]; // } // ``` @@ -1265,31 +1265,31 @@ message Int64Rules { id: "int64.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "int64.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "int64.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "int64.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "int64.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -1300,13 +1300,13 @@ message Int64Rules { // // ```proto // message MyInt64 { - // // value must be in list [1, 2, 3] + // // must be in list [1, 2, 3] // int64 value = 1 [(buf.validate.field).int64 = { in: [1, 2, 3] }]; // } // ``` repeated int64 in = 6 [(predefined).cel = { id: "int64.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -1321,7 +1321,7 @@ message Int64Rules { // ``` repeated int64 not_in = 7 [(predefined).cel = { id: "int64.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -1361,7 +1361,7 @@ message UInt32Rules { // ``` optional uint32 const = 1 [(predefined).cel = { id: "uint32.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -1370,7 +1370,7 @@ message UInt32Rules { // // ```proto // message MyUInt32 { - // // value must be less than 10 + // // must be less than 10 // uint32 value = 1 [(buf.validate.field).uint32.lt = 10]; // } // ``` @@ -1378,7 +1378,7 @@ message UInt32Rules { id: "uint32.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -1387,7 +1387,7 @@ message UInt32Rules { // // ```proto // message MyUInt32 { - // // value must be less than or equal to 10 + // // must be less than or equal to 10 // uint32 value = 1 [(buf.validate.field).uint32.lte = 10]; // } // ``` @@ -1395,7 +1395,7 @@ message UInt32Rules { id: "uint32.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -1407,13 +1407,13 @@ message UInt32Rules { // // ```proto // message MyUInt32 { - // // value must be greater than 5 [uint32.gt] + // // must be greater than 5 [uint32.gt] // uint32 value = 1 [(buf.validate.field).uint32.gt = 5]; // - // // value must be greater than 5 and less than 10 [uint32.gt_lt] + // // must be greater than 5 and less than 10 [uint32.gt_lt] // uint32 other_value = 2 [(buf.validate.field).uint32 = { gt: 5, lt: 10 }]; // - // // value must be greater than 10 or less than 5 [uint32.gt_lt_exclusive] + // // must be greater than 10 or less than 5 [uint32.gt_lt_exclusive] // uint32 another_value = 3 [(buf.validate.field).uint32 = { gt: 10, lt: 5 }]; // } // ``` @@ -1422,31 +1422,31 @@ message UInt32Rules { id: "uint32.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "uint32.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "uint32.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "uint32.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "uint32.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -1458,13 +1458,13 @@ message UInt32Rules { // // ```proto // message MyUInt32 { - // // value must be greater than or equal to 5 [uint32.gte] + // // must be greater than or equal to 5 [uint32.gte] // uint32 value = 1 [(buf.validate.field).uint32.gte = 5]; // - // // value must be greater than or equal to 5 and less than 10 [uint32.gte_lt] + // // must be greater than or equal to 5 and less than 10 [uint32.gte_lt] // uint32 other_value = 2 [(buf.validate.field).uint32 = { gte: 5, lt: 10 }]; // - // // value must be greater than or equal to 10 or less than 5 [uint32.gte_lt_exclusive] + // // must be greater than or equal to 10 or less than 5 [uint32.gte_lt_exclusive] // uint32 another_value = 3 [(buf.validate.field).uint32 = { gte: 10, lt: 5 }]; // } // ``` @@ -1473,31 +1473,31 @@ message UInt32Rules { id: "uint32.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "uint32.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "uint32.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "uint32.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "uint32.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -1508,13 +1508,13 @@ message UInt32Rules { // // ```proto // message MyUInt32 { - // // value must be in list [1, 2, 3] + // // must be in list [1, 2, 3] // uint32 value = 1 [(buf.validate.field).uint32 = { in: [1, 2, 3] }]; // } // ``` repeated uint32 in = 6 [(predefined).cel = { id: "uint32.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -1529,7 +1529,7 @@ message UInt32Rules { // ``` repeated uint32 not_in = 7 [(predefined).cel = { id: "uint32.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -1569,7 +1569,7 @@ message UInt64Rules { // ``` optional uint64 const = 1 [(predefined).cel = { id: "uint64.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -1578,7 +1578,7 @@ message UInt64Rules { // // ```proto // message MyUInt64 { - // // value must be less than 10 + // // must be less than 10 // uint64 value = 1 [(buf.validate.field).uint64.lt = 10]; // } // ``` @@ -1586,7 +1586,7 @@ message UInt64Rules { id: "uint64.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -1595,7 +1595,7 @@ message UInt64Rules { // // ```proto // message MyUInt64 { - // // value must be less than or equal to 10 + // // must be less than or equal to 10 // uint64 value = 1 [(buf.validate.field).uint64.lte = 10]; // } // ``` @@ -1603,7 +1603,7 @@ message UInt64Rules { id: "uint64.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -1615,13 +1615,13 @@ message UInt64Rules { // // ```proto // message MyUInt64 { - // // value must be greater than 5 [uint64.gt] + // // must be greater than 5 [uint64.gt] // uint64 value = 1 [(buf.validate.field).uint64.gt = 5]; // - // // value must be greater than 5 and less than 10 [uint64.gt_lt] + // // must be greater than 5 and less than 10 [uint64.gt_lt] // uint64 other_value = 2 [(buf.validate.field).uint64 = { gt: 5, lt: 10 }]; // - // // value must be greater than 10 or less than 5 [uint64.gt_lt_exclusive] + // // must be greater than 10 or less than 5 [uint64.gt_lt_exclusive] // uint64 another_value = 3 [(buf.validate.field).uint64 = { gt: 10, lt: 5 }]; // } // ``` @@ -1630,31 +1630,31 @@ message UInt64Rules { id: "uint64.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "uint64.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "uint64.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "uint64.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "uint64.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -1666,13 +1666,13 @@ message UInt64Rules { // // ```proto // message MyUInt64 { - // // value must be greater than or equal to 5 [uint64.gte] + // // must be greater than or equal to 5 [uint64.gte] // uint64 value = 1 [(buf.validate.field).uint64.gte = 5]; // - // // value must be greater than or equal to 5 and less than 10 [uint64.gte_lt] + // // must be greater than or equal to 5 and less than 10 [uint64.gte_lt] // uint64 other_value = 2 [(buf.validate.field).uint64 = { gte: 5, lt: 10 }]; // - // // value must be greater than or equal to 10 or less than 5 [uint64.gte_lt_exclusive] + // // must be greater than or equal to 10 or less than 5 [uint64.gte_lt_exclusive] // uint64 another_value = 3 [(buf.validate.field).uint64 = { gte: 10, lt: 5 }]; // } // ``` @@ -1681,31 +1681,31 @@ message UInt64Rules { id: "uint64.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "uint64.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "uint64.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "uint64.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "uint64.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -1715,13 +1715,13 @@ message UInt64Rules { // // ```proto // message MyUInt64 { - // // value must be in list [1, 2, 3] + // // must be in list [1, 2, 3] // uint64 value = 1 [(buf.validate.field).uint64 = { in: [1, 2, 3] }]; // } // ``` repeated uint64 in = 6 [(predefined).cel = { id: "uint64.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -1736,7 +1736,7 @@ message UInt64Rules { // ``` repeated uint64 not_in = 7 [(predefined).cel = { id: "uint64.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -1775,7 +1775,7 @@ message SInt32Rules { // ``` optional sint32 const = 1 [(predefined).cel = { id: "sint32.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field @@ -1784,7 +1784,7 @@ message SInt32Rules { // // ```proto // message MySInt32 { - // // value must be less than 10 + // // must be less than 10 // sint32 value = 1 [(buf.validate.field).sint32.lt = 10]; // } // ``` @@ -1792,7 +1792,7 @@ message SInt32Rules { id: "sint32.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -1801,7 +1801,7 @@ message SInt32Rules { // // ```proto // message MySInt32 { - // // value must be less than or equal to 10 + // // must be less than or equal to 10 // sint32 value = 1 [(buf.validate.field).sint32.lte = 10]; // } // ``` @@ -1809,7 +1809,7 @@ message SInt32Rules { id: "sint32.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -1821,13 +1821,13 @@ message SInt32Rules { // // ```proto // message MySInt32 { - // // value must be greater than 5 [sint32.gt] + // // must be greater than 5 [sint32.gt] // sint32 value = 1 [(buf.validate.field).sint32.gt = 5]; // - // // value must be greater than 5 and less than 10 [sint32.gt_lt] + // // must be greater than 5 and less than 10 [sint32.gt_lt] // sint32 other_value = 2 [(buf.validate.field).sint32 = { gt: 5, lt: 10 }]; // - // // value must be greater than 10 or less than 5 [sint32.gt_lt_exclusive] + // // must be greater than 10 or less than 5 [sint32.gt_lt_exclusive] // sint32 another_value = 3 [(buf.validate.field).sint32 = { gt: 10, lt: 5 }]; // } // ``` @@ -1836,31 +1836,31 @@ message SInt32Rules { id: "sint32.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "sint32.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "sint32.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "sint32.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "sint32.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -1872,13 +1872,13 @@ message SInt32Rules { // // ```proto // message MySInt32 { - // // value must be greater than or equal to 5 [sint32.gte] + // // must be greater than or equal to 5 [sint32.gte] // sint32 value = 1 [(buf.validate.field).sint32.gte = 5]; // - // // value must be greater than or equal to 5 and less than 10 [sint32.gte_lt] + // // must be greater than or equal to 5 and less than 10 [sint32.gte_lt] // sint32 other_value = 2 [(buf.validate.field).sint32 = { gte: 5, lt: 10 }]; // - // // value must be greater than or equal to 10 or less than 5 [sint32.gte_lt_exclusive] + // // must be greater than or equal to 10 or less than 5 [sint32.gte_lt_exclusive] // sint32 another_value = 3 [(buf.validate.field).sint32 = { gte: 10, lt: 5 }]; // } // ``` @@ -1887,31 +1887,31 @@ message SInt32Rules { id: "sint32.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "sint32.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "sint32.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "sint32.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "sint32.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -1922,13 +1922,13 @@ message SInt32Rules { // // ```proto // message MySInt32 { - // // value must be in list [1, 2, 3] + // // must be in list [1, 2, 3] // sint32 value = 1 [(buf.validate.field).sint32 = { in: [1, 2, 3] }]; // } // ``` repeated sint32 in = 6 [(predefined).cel = { id: "sint32.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -1943,7 +1943,7 @@ message SInt32Rules { // ``` repeated sint32 not_in = 7 [(predefined).cel = { id: "sint32.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -1982,7 +1982,7 @@ message SInt64Rules { // ``` optional sint64 const = 1 [(predefined).cel = { id: "sint64.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field @@ -1991,7 +1991,7 @@ message SInt64Rules { // // ```proto // message MySInt64 { - // // value must be less than 10 + // // must be less than 10 // sint64 value = 1 [(buf.validate.field).sint64.lt = 10]; // } // ``` @@ -1999,7 +1999,7 @@ message SInt64Rules { id: "sint64.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -2008,7 +2008,7 @@ message SInt64Rules { // // ```proto // message MySInt64 { - // // value must be less than or equal to 10 + // // must be less than or equal to 10 // sint64 value = 1 [(buf.validate.field).sint64.lte = 10]; // } // ``` @@ -2016,7 +2016,7 @@ message SInt64Rules { id: "sint64.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -2028,13 +2028,13 @@ message SInt64Rules { // // ```proto // message MySInt64 { - // // value must be greater than 5 [sint64.gt] + // // must be greater than 5 [sint64.gt] // sint64 value = 1 [(buf.validate.field).sint64.gt = 5]; // - // // value must be greater than 5 and less than 10 [sint64.gt_lt] + // // must be greater than 5 and less than 10 [sint64.gt_lt] // sint64 other_value = 2 [(buf.validate.field).sint64 = { gt: 5, lt: 10 }]; // - // // value must be greater than 10 or less than 5 [sint64.gt_lt_exclusive] + // // must be greater than 10 or less than 5 [sint64.gt_lt_exclusive] // sint64 another_value = 3 [(buf.validate.field).sint64 = { gt: 10, lt: 5 }]; // } // ``` @@ -2043,31 +2043,31 @@ message SInt64Rules { id: "sint64.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "sint64.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "sint64.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "sint64.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "sint64.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -2079,13 +2079,13 @@ message SInt64Rules { // // ```proto // message MySInt64 { - // // value must be greater than or equal to 5 [sint64.gte] + // // must be greater than or equal to 5 [sint64.gte] // sint64 value = 1 [(buf.validate.field).sint64.gte = 5]; // - // // value must be greater than or equal to 5 and less than 10 [sint64.gte_lt] + // // must be greater than or equal to 5 and less than 10 [sint64.gte_lt] // sint64 other_value = 2 [(buf.validate.field).sint64 = { gte: 5, lt: 10 }]; // - // // value must be greater than or equal to 10 or less than 5 [sint64.gte_lt_exclusive] + // // must be greater than or equal to 10 or less than 5 [sint64.gte_lt_exclusive] // sint64 another_value = 3 [(buf.validate.field).sint64 = { gte: 10, lt: 5 }]; // } // ``` @@ -2094,31 +2094,31 @@ message SInt64Rules { id: "sint64.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "sint64.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "sint64.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "sint64.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "sint64.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -2129,13 +2129,13 @@ message SInt64Rules { // // ```proto // message MySInt64 { - // // value must be in list [1, 2, 3] + // // must be in list [1, 2, 3] // sint64 value = 1 [(buf.validate.field).sint64 = { in: [1, 2, 3] }]; // } // ``` repeated sint64 in = 6 [(predefined).cel = { id: "sint64.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -2150,7 +2150,7 @@ message SInt64Rules { // ``` repeated sint64 not_in = 7 [(predefined).cel = { id: "sint64.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -2189,7 +2189,7 @@ message Fixed32Rules { // ``` optional fixed32 const = 1 [(predefined).cel = { id: "fixed32.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -2198,7 +2198,7 @@ message Fixed32Rules { // // ```proto // message MyFixed32 { - // // value must be less than 10 + // // must be less than 10 // fixed32 value = 1 [(buf.validate.field).fixed32.lt = 10]; // } // ``` @@ -2206,7 +2206,7 @@ message Fixed32Rules { id: "fixed32.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -2215,7 +2215,7 @@ message Fixed32Rules { // // ```proto // message MyFixed32 { - // // value must be less than or equal to 10 + // // must be less than or equal to 10 // fixed32 value = 1 [(buf.validate.field).fixed32.lte = 10]; // } // ``` @@ -2223,7 +2223,7 @@ message Fixed32Rules { id: "fixed32.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -2235,13 +2235,13 @@ message Fixed32Rules { // // ```proto // message MyFixed32 { - // // value must be greater than 5 [fixed32.gt] + // // must be greater than 5 [fixed32.gt] // fixed32 value = 1 [(buf.validate.field).fixed32.gt = 5]; // - // // value must be greater than 5 and less than 10 [fixed32.gt_lt] + // // must be greater than 5 and less than 10 [fixed32.gt_lt] // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gt: 5, lt: 10 }]; // - // // value must be greater than 10 or less than 5 [fixed32.gt_lt_exclusive] + // // must be greater than 10 or less than 5 [fixed32.gt_lt_exclusive] // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gt: 10, lt: 5 }]; // } // ``` @@ -2250,31 +2250,31 @@ message Fixed32Rules { id: "fixed32.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "fixed32.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "fixed32.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "fixed32.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "fixed32.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -2286,13 +2286,13 @@ message Fixed32Rules { // // ```proto // message MyFixed32 { - // // value must be greater than or equal to 5 [fixed32.gte] + // // must be greater than or equal to 5 [fixed32.gte] // fixed32 value = 1 [(buf.validate.field).fixed32.gte = 5]; // - // // value must be greater than or equal to 5 and less than 10 [fixed32.gte_lt] + // // must be greater than or equal to 5 and less than 10 [fixed32.gte_lt] // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gte: 5, lt: 10 }]; // - // // value must be greater than or equal to 10 or less than 5 [fixed32.gte_lt_exclusive] + // // must be greater than or equal to 10 or less than 5 [fixed32.gte_lt_exclusive] // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gte: 10, lt: 5 }]; // } // ``` @@ -2301,31 +2301,31 @@ message Fixed32Rules { id: "fixed32.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "fixed32.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "fixed32.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "fixed32.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "fixed32.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -2336,13 +2336,13 @@ message Fixed32Rules { // // ```proto // message MyFixed32 { - // // value must be in list [1, 2, 3] + // // must be in list [1, 2, 3] // fixed32 value = 1 [(buf.validate.field).fixed32 = { in: [1, 2, 3] }]; // } // ``` repeated fixed32 in = 6 [(predefined).cel = { id: "fixed32.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -2357,7 +2357,7 @@ message Fixed32Rules { // ``` repeated fixed32 not_in = 7 [(predefined).cel = { id: "fixed32.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -2396,7 +2396,7 @@ message Fixed64Rules { // ``` optional fixed64 const = 1 [(predefined).cel = { id: "fixed64.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -2405,7 +2405,7 @@ message Fixed64Rules { // // ```proto // message MyFixed64 { - // // value must be less than 10 + // // must be less than 10 // fixed64 value = 1 [(buf.validate.field).fixed64.lt = 10]; // } // ``` @@ -2413,7 +2413,7 @@ message Fixed64Rules { id: "fixed64.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -2422,7 +2422,7 @@ message Fixed64Rules { // // ```proto // message MyFixed64 { - // // value must be less than or equal to 10 + // // must be less than or equal to 10 // fixed64 value = 1 [(buf.validate.field).fixed64.lte = 10]; // } // ``` @@ -2430,7 +2430,7 @@ message Fixed64Rules { id: "fixed64.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -2442,13 +2442,13 @@ message Fixed64Rules { // // ```proto // message MyFixed64 { - // // value must be greater than 5 [fixed64.gt] + // // must be greater than 5 [fixed64.gt] // fixed64 value = 1 [(buf.validate.field).fixed64.gt = 5]; // - // // value must be greater than 5 and less than 10 [fixed64.gt_lt] + // // must be greater than 5 and less than 10 [fixed64.gt_lt] // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gt: 5, lt: 10 }]; // - // // value must be greater than 10 or less than 5 [fixed64.gt_lt_exclusive] + // // must be greater than 10 or less than 5 [fixed64.gt_lt_exclusive] // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gt: 10, lt: 5 }]; // } // ``` @@ -2457,31 +2457,31 @@ message Fixed64Rules { id: "fixed64.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "fixed64.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "fixed64.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "fixed64.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "fixed64.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -2493,13 +2493,13 @@ message Fixed64Rules { // // ```proto // message MyFixed64 { - // // value must be greater than or equal to 5 [fixed64.gte] + // // must be greater than or equal to 5 [fixed64.gte] // fixed64 value = 1 [(buf.validate.field).fixed64.gte = 5]; // - // // value must be greater than or equal to 5 and less than 10 [fixed64.gte_lt] + // // must be greater than or equal to 5 and less than 10 [fixed64.gte_lt] // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gte: 5, lt: 10 }]; // - // // value must be greater than or equal to 10 or less than 5 [fixed64.gte_lt_exclusive] + // // must be greater than or equal to 10 or less than 5 [fixed64.gte_lt_exclusive] // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gte: 10, lt: 5 }]; // } // ``` @@ -2508,31 +2508,31 @@ message Fixed64Rules { id: "fixed64.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "fixed64.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "fixed64.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "fixed64.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "fixed64.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -2543,13 +2543,13 @@ message Fixed64Rules { // // ```proto // message MyFixed64 { - // // value must be in list [1, 2, 3] + // // must be in list [1, 2, 3] // fixed64 value = 1 [(buf.validate.field).fixed64 = { in: [1, 2, 3] }]; // } // ``` repeated fixed64 in = 6 [(predefined).cel = { id: "fixed64.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -2564,7 +2564,7 @@ message Fixed64Rules { // ``` repeated fixed64 not_in = 7 [(predefined).cel = { id: "fixed64.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -2603,7 +2603,7 @@ message SFixed32Rules { // ``` optional sfixed32 const = 1 [(predefined).cel = { id: "sfixed32.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -2612,7 +2612,7 @@ message SFixed32Rules { // // ```proto // message MySFixed32 { - // // value must be less than 10 + // // must be less than 10 // sfixed32 value = 1 [(buf.validate.field).sfixed32.lt = 10]; // } // ``` @@ -2620,7 +2620,7 @@ message SFixed32Rules { id: "sfixed32.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -2629,7 +2629,7 @@ message SFixed32Rules { // // ```proto // message MySFixed32 { - // // value must be less than or equal to 10 + // // must be less than or equal to 10 // sfixed32 value = 1 [(buf.validate.field).sfixed32.lte = 10]; // } // ``` @@ -2637,7 +2637,7 @@ message SFixed32Rules { id: "sfixed32.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -2649,13 +2649,13 @@ message SFixed32Rules { // // ```proto // message MySFixed32 { - // // value must be greater than 5 [sfixed32.gt] + // // must be greater than 5 [sfixed32.gt] // sfixed32 value = 1 [(buf.validate.field).sfixed32.gt = 5]; // - // // value must be greater than 5 and less than 10 [sfixed32.gt_lt] + // // must be greater than 5 and less than 10 [sfixed32.gt_lt] // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gt: 5, lt: 10 }]; // - // // value must be greater than 10 or less than 5 [sfixed32.gt_lt_exclusive] + // // must be greater than 10 or less than 5 [sfixed32.gt_lt_exclusive] // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gt: 10, lt: 5 }]; // } // ``` @@ -2664,31 +2664,31 @@ message SFixed32Rules { id: "sfixed32.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "sfixed32.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "sfixed32.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "sfixed32.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "sfixed32.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -2700,13 +2700,13 @@ message SFixed32Rules { // // ```proto // message MySFixed32 { - // // value must be greater than or equal to 5 [sfixed32.gte] + // // must be greater than or equal to 5 [sfixed32.gte] // sfixed32 value = 1 [(buf.validate.field).sfixed32.gte = 5]; // - // // value must be greater than or equal to 5 and less than 10 [sfixed32.gte_lt] + // // must be greater than or equal to 5 and less than 10 [sfixed32.gte_lt] // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gte: 5, lt: 10 }]; // - // // value must be greater than or equal to 10 or less than 5 [sfixed32.gte_lt_exclusive] + // // must be greater than or equal to 10 or less than 5 [sfixed32.gte_lt_exclusive] // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gte: 10, lt: 5 }]; // } // ``` @@ -2715,31 +2715,31 @@ message SFixed32Rules { id: "sfixed32.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "sfixed32.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "sfixed32.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "sfixed32.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "sfixed32.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -2750,13 +2750,13 @@ message SFixed32Rules { // // ```proto // message MySFixed32 { - // // value must be in list [1, 2, 3] + // // must be in list [1, 2, 3] // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { in: [1, 2, 3] }]; // } // ``` repeated sfixed32 in = 6 [(predefined).cel = { id: "sfixed32.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -2771,7 +2771,7 @@ message SFixed32Rules { // ``` repeated sfixed32 not_in = 7 [(predefined).cel = { id: "sfixed32.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -2810,7 +2810,7 @@ message SFixed64Rules { // ``` optional sfixed64 const = 1 [(predefined).cel = { id: "sfixed64.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -2819,7 +2819,7 @@ message SFixed64Rules { // // ```proto // message MySFixed64 { - // // value must be less than 10 + // // must be less than 10 // sfixed64 value = 1 [(buf.validate.field).sfixed64.lt = 10]; // } // ``` @@ -2827,7 +2827,7 @@ message SFixed64Rules { id: "sfixed64.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` requires the field value to be less than or equal to the specified @@ -2836,7 +2836,7 @@ message SFixed64Rules { // // ```proto // message MySFixed64 { - // // value must be less than or equal to 10 + // // must be less than or equal to 10 // sfixed64 value = 1 [(buf.validate.field).sfixed64.lte = 10]; // } // ``` @@ -2844,7 +2844,7 @@ message SFixed64Rules { id: "sfixed64.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -2856,13 +2856,13 @@ message SFixed64Rules { // // ```proto // message MySFixed64 { - // // value must be greater than 5 [sfixed64.gt] + // // must be greater than 5 [sfixed64.gt] // sfixed64 value = 1 [(buf.validate.field).sfixed64.gt = 5]; // - // // value must be greater than 5 and less than 10 [sfixed64.gt_lt] + // // must be greater than 5 and less than 10 [sfixed64.gt_lt] // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gt: 5, lt: 10 }]; // - // // value must be greater than 10 or less than 5 [sfixed64.gt_lt_exclusive] + // // must be greater than 10 or less than 5 [sfixed64.gt_lt_exclusive] // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gt: 10, lt: 5 }]; // } // ``` @@ -2871,31 +2871,31 @@ message SFixed64Rules { id: "sfixed64.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "sfixed64.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "sfixed64.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "sfixed64.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "sfixed64.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -2907,13 +2907,13 @@ message SFixed64Rules { // // ```proto // message MySFixed64 { - // // value must be greater than or equal to 5 [sfixed64.gte] + // // must be greater than or equal to 5 [sfixed64.gte] // sfixed64 value = 1 [(buf.validate.field).sfixed64.gte = 5]; // - // // value must be greater than or equal to 5 and less than 10 [sfixed64.gte_lt] + // // must be greater than or equal to 5 and less than 10 [sfixed64.gte_lt] // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gte: 5, lt: 10 }]; // - // // value must be greater than or equal to 10 or less than 5 [sfixed64.gte_lt_exclusive] + // // must be greater than or equal to 10 or less than 5 [sfixed64.gte_lt_exclusive] // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gte: 10, lt: 5 }]; // } // ``` @@ -2922,31 +2922,31 @@ message SFixed64Rules { id: "sfixed64.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "sfixed64.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "sfixed64.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "sfixed64.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "sfixed64.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -2957,13 +2957,13 @@ message SFixed64Rules { // // ```proto // message MySFixed64 { - // // value must be in list [1, 2, 3] + // // must be in list [1, 2, 3] // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { in: [1, 2, 3] }]; // } // ``` repeated sfixed64 in = 6 [(predefined).cel = { id: "sfixed64.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -2978,7 +2978,7 @@ message SFixed64Rules { // ``` repeated sfixed64 not_in = 7 [(predefined).cel = { id: "sfixed64.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -3018,7 +3018,7 @@ message BoolRules { // ``` optional bool const = 1 [(predefined).cel = { id: "bool.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -3058,7 +3058,7 @@ message StringRules { // ``` optional string const = 1 [(predefined).cel = { id: "string.const" - expression: "this != getField(rules, 'const') ? 'value must equal `%s`'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal `%s`'.format([getField(rules, 'const')]) : ''" }]; // `len` dictates that the field value must have the specified @@ -3074,7 +3074,7 @@ message StringRules { // ``` optional uint64 len = 19 [(predefined).cel = { id: "string.len" - expression: "uint(this.size()) != rules.len ? 'value length must be %s characters'.format([rules.len]) : ''" + expression: "uint(this.size()) != rules.len ? 'must be %s characters'.format([rules.len]) : ''" }]; // `min_len` specifies that the field value must have at least the specified @@ -3090,7 +3090,7 @@ message StringRules { // ``` optional uint64 min_len = 2 [(predefined).cel = { id: "string.min_len" - expression: "uint(this.size()) < rules.min_len ? 'value length must be at least %s characters'.format([rules.min_len]) : ''" + expression: "uint(this.size()) < rules.min_len ? 'must be at least %s characters'.format([rules.min_len]) : ''" }]; // `max_len` specifies that the field value must have no more than the specified @@ -3106,7 +3106,7 @@ message StringRules { // ``` optional uint64 max_len = 3 [(predefined).cel = { id: "string.max_len" - expression: "uint(this.size()) > rules.max_len ? 'value length must be at most %s characters'.format([rules.max_len]) : ''" + expression: "uint(this.size()) > rules.max_len ? 'must be at most %s characters'.format([rules.max_len]) : ''" }]; // `len_bytes` dictates that the field value must have the specified number of @@ -3121,7 +3121,7 @@ message StringRules { // ``` optional uint64 len_bytes = 20 [(predefined).cel = { id: "string.len_bytes" - expression: "uint(bytes(this).size()) != rules.len_bytes ? 'value length must be %s bytes'.format([rules.len_bytes]) : ''" + expression: "uint(bytes(this).size()) != rules.len_bytes ? 'must be %s bytes'.format([rules.len_bytes]) : ''" }]; // `min_bytes` specifies that the field value must have at least the specified @@ -3137,11 +3137,11 @@ message StringRules { // ``` optional uint64 min_bytes = 4 [(predefined).cel = { id: "string.min_bytes" - expression: "uint(bytes(this).size()) < rules.min_bytes ? 'value length must be at least %s bytes'.format([rules.min_bytes]) : ''" + expression: "uint(bytes(this).size()) < rules.min_bytes ? 'must be at least %s bytes'.format([rules.min_bytes]) : ''" }]; // `max_bytes` specifies that the field value must have no more than the - //specified number of bytes. If the field value contains more bytes, an + // specified number of bytes. If the field value contains more bytes, an // error message will be generated. // // ```proto @@ -3152,7 +3152,7 @@ message StringRules { // ``` optional uint64 max_bytes = 5 [(predefined).cel = { id: "string.max_bytes" - expression: "uint(bytes(this).size()) > rules.max_bytes ? 'value length must be at most %s bytes'.format([rules.max_bytes]) : ''" + expression: "uint(bytes(this).size()) > rules.max_bytes ? 'must be at most %s bytes'.format([rules.max_bytes]) : ''" }]; // `pattern` specifies that the field value must match the specified @@ -3168,11 +3168,11 @@ message StringRules { // ``` optional string pattern = 6 [(predefined).cel = { id: "string.pattern" - expression: "!this.matches(rules.pattern) ? 'value does not match regex pattern `%s`'.format([rules.pattern]) : ''" + expression: "!this.matches(rules.pattern) ? 'does not match regex pattern `%s`'.format([rules.pattern]) : ''" }]; // `prefix` specifies that the field value must have the - //specified substring at the beginning of the string. If the field value + // specified substring at the beginning of the string. If the field value // doesn't start with the specified prefix, an error message will be // generated. // @@ -3184,11 +3184,11 @@ message StringRules { // ``` optional string prefix = 7 [(predefined).cel = { id: "string.prefix" - expression: "!this.startsWith(rules.prefix) ? 'value does not have prefix `%s`'.format([rules.prefix]) : ''" + expression: "!this.startsWith(rules.prefix) ? 'does not have prefix `%s`'.format([rules.prefix]) : ''" }]; // `suffix` specifies that the field value must have the - //specified substring at the end of the string. If the field value doesn't + // specified substring at the end of the string. If the field value doesn't // end with the specified suffix, an error message will be generated. // // ```proto @@ -3199,11 +3199,11 @@ message StringRules { // ``` optional string suffix = 8 [(predefined).cel = { id: "string.suffix" - expression: "!this.endsWith(rules.suffix) ? 'value does not have suffix `%s`'.format([rules.suffix]) : ''" + expression: "!this.endsWith(rules.suffix) ? 'does not have suffix `%s`'.format([rules.suffix]) : ''" }]; // `contains` specifies that the field value must have the - //specified substring anywhere in the string. If the field value doesn't + // specified substring anywhere in the string. If the field value doesn't // contain the specified substring, an error message will be generated. // // ```proto @@ -3214,11 +3214,11 @@ message StringRules { // ``` optional string contains = 9 [(predefined).cel = { id: "string.contains" - expression: "!this.contains(rules.contains) ? 'value does not contain substring `%s`'.format([rules.contains]) : ''" + expression: "!this.contains(rules.contains) ? 'does not contain substring `%s`'.format([rules.contains]) : ''" }]; // `not_contains` specifies that the field value must not have the - //specified substring anywhere in the string. If the field value contains + // specified substring anywhere in the string. If the field value contains // the specified substring, an error message will be generated. // // ```proto @@ -3229,7 +3229,7 @@ message StringRules { // ``` optional string not_contains = 23 [(predefined).cel = { id: "string.not_contains" - expression: "this.contains(rules.not_contains) ? 'value contains substring `%s`'.format([rules.not_contains]) : ''" + expression: "this.contains(rules.not_contains) ? 'contains substring `%s`'.format([rules.not_contains]) : ''" }]; // `in` specifies that the field value must be equal to one of the specified @@ -3238,13 +3238,13 @@ message StringRules { // // ```proto // message MyString { - // // value must be in list ["apple", "banana"] + // // must be in list ["apple", "banana"] // string value = 1 [(buf.validate.field).string.in = "apple", (buf.validate.field).string.in = "banana"]; // } // ``` repeated string in = 10 [(predefined).cel = { id: "string.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` specifies that the field value cannot be equal to any @@ -3258,7 +3258,7 @@ message StringRules { // ``` repeated string not_in = 11 [(predefined).cel = { id: "string.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `WellKnown` rules provide advanced rules against common string @@ -3276,14 +3276,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid email address + // // must be a valid email address // string value = 1 [(buf.validate.field).string.email = true]; // } // ``` bool email = 12 [ (predefined).cel = { id: "string.email" - message: "value must be a valid email address" + message: "must be a valid email address" expression: "!rules.email || this == '' || this.isEmail()" }, (predefined).cel = { @@ -3308,14 +3308,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid hostname + // // must be a valid hostname // string value = 1 [(buf.validate.field).string.hostname = true]; // } // ``` bool hostname = 13 [ (predefined).cel = { id: "string.hostname" - message: "value must be a valid hostname" + message: "must be a valid hostname" expression: "!rules.hostname || this == '' || this.isHostname()" }, (predefined).cel = { @@ -3339,14 +3339,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid IP address + // // must be a valid IP address // string value = 1 [(buf.validate.field).string.ip = true]; // } // ``` bool ip = 14 [ (predefined).cel = { id: "string.ip" - message: "value must be a valid IP address" + message: "must be a valid IP address" expression: "!rules.ip || this == '' || this.isIp()" }, (predefined).cel = { @@ -3362,14 +3362,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid IPv4 address + // // must be a valid IPv4 address // string value = 1 [(buf.validate.field).string.ipv4 = true]; // } // ``` bool ipv4 = 15 [ (predefined).cel = { id: "string.ipv4" - message: "value must be a valid IPv4 address" + message: "must be a valid IPv4 address" expression: "!rules.ipv4 || this == '' || this.isIp(4)" }, (predefined).cel = { @@ -3385,14 +3385,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid IPv6 address + // // must be a valid IPv6 address // string value = 1 [(buf.validate.field).string.ipv6 = true]; // } // ``` bool ipv6 = 16 [ (predefined).cel = { id: "string.ipv6" - message: "value must be a valid IPv6 address" + message: "must be a valid IPv6 address" expression: "!rules.ipv6 || this == '' || this.isIp(6)" }, (predefined).cel = { @@ -3412,14 +3412,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid URI + // // must be a valid URI // string value = 1 [(buf.validate.field).string.uri = true]; // } // ``` bool uri = 17 [ (predefined).cel = { id: "string.uri" - message: "value must be a valid URI" + message: "must be a valid URI" expression: "!rules.uri || this == '' || this.isUri()" }, (predefined).cel = { @@ -3442,13 +3442,13 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid URI Reference + // // must be a valid URI Reference // string value = 1 [(buf.validate.field).string.uri_ref = true]; // } // ``` bool uri_ref = 18 [(predefined).cel = { id: "string.uri_ref" - message: "value must be a valid URI Reference" + message: "must be a valid URI Reference" expression: "!rules.uri_ref || this.isUriRef()" }]; @@ -3459,14 +3459,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid hostname, or ip address + // // must be a valid hostname, or ip address // string value = 1 [(buf.validate.field).string.address = true]; // } // ``` bool address = 21 [ (predefined).cel = { id: "string.address" - message: "value must be a valid hostname, or ip address" + message: "must be a valid hostname, or ip address" expression: "!rules.address || this == '' || this.isHostname() || this.isIp()" }, (predefined).cel = { @@ -3482,14 +3482,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid UUID + // // must be a valid UUID // string value = 1 [(buf.validate.field).string.uuid = true]; // } // ``` bool uuid = 22 [ (predefined).cel = { id: "string.uuid" - message: "value must be a valid UUID" + message: "must be a valid UUID" expression: "!rules.uuid || this == '' || this.matches('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')" }, (predefined).cel = { @@ -3506,14 +3506,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid trimmed UUID + // // must be a valid trimmed UUID // string value = 1 [(buf.validate.field).string.tuuid = true]; // } // ``` bool tuuid = 33 [ (predefined).cel = { id: "string.tuuid" - message: "value must be a valid trimmed UUID" + message: "must be a valid trimmed UUID" expression: "!rules.tuuid || this == '' || this.matches('^[0-9a-fA-F]{32}$')" }, (predefined).cel = { @@ -3530,14 +3530,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid IP with prefix length + // // must be a valid IP with prefix length // string value = 1 [(buf.validate.field).string.ip_with_prefixlen = true]; // } // ``` bool ip_with_prefixlen = 26 [ (predefined).cel = { id: "string.ip_with_prefixlen" - message: "value must be a valid IP prefix" + message: "must be a valid IP prefix" expression: "!rules.ip_with_prefixlen || this == '' || this.isIpPrefix()" }, (predefined).cel = { @@ -3554,14 +3554,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid IPv4 address with prefix length + // // must be a valid IPv4 address with prefix length // string value = 1 [(buf.validate.field).string.ipv4_with_prefixlen = true]; // } // ``` bool ipv4_with_prefixlen = 27 [ (predefined).cel = { id: "string.ipv4_with_prefixlen" - message: "value must be a valid IPv4 address with prefix length" + message: "must be a valid IPv4 address with prefix length" expression: "!rules.ipv4_with_prefixlen || this == '' || this.isIpPrefix(4)" }, (predefined).cel = { @@ -3578,14 +3578,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid IPv6 address prefix length + // // must be a valid IPv6 address prefix length // string value = 1 [(buf.validate.field).string.ipv6_with_prefixlen = true]; // } // ``` bool ipv6_with_prefixlen = 28 [ (predefined).cel = { id: "string.ipv6_with_prefixlen" - message: "value must be a valid IPv6 address with prefix length" + message: "must be a valid IPv6 address with prefix length" expression: "!rules.ipv6_with_prefixlen || this == '' || this.isIpPrefix(6)" }, (predefined).cel = { @@ -3607,14 +3607,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid IP prefix + // // must be a valid IP prefix // string value = 1 [(buf.validate.field).string.ip_prefix = true]; // } // ``` bool ip_prefix = 29 [ (predefined).cel = { id: "string.ip_prefix" - message: "value must be a valid IP prefix" + message: "must be a valid IP prefix" expression: "!rules.ip_prefix || this == '' || this.isIpPrefix(true)" }, (predefined).cel = { @@ -3636,14 +3636,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid IPv4 prefix + // // must be a valid IPv4 prefix // string value = 1 [(buf.validate.field).string.ipv4_prefix = true]; // } // ``` bool ipv4_prefix = 30 [ (predefined).cel = { id: "string.ipv4_prefix" - message: "value must be a valid IPv4 prefix" + message: "must be a valid IPv4 prefix" expression: "!rules.ipv4_prefix || this == '' || this.isIpPrefix(4, true)" }, (predefined).cel = { @@ -3665,14 +3665,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid IPv6 prefix + // // must be a valid IPv6 prefix // string value = 1 [(buf.validate.field).string.ipv6_prefix = true]; // } // ``` bool ipv6_prefix = 31 [ (predefined).cel = { id: "string.ipv6_prefix" - message: "value must be a valid IPv6 prefix" + message: "must be a valid IPv6 prefix" expression: "!rules.ipv6_prefix || this == '' || this.isIpPrefix(6, true)" }, (predefined).cel = { @@ -3682,20 +3682,20 @@ message StringRules { } ]; - // `host_and_port` specifies that the field value must be valid host/port + // `host_and_port` specifies that the field value must be a valid host/port // pair—for example, "example.com:8080". // // The host can be one of: - //- An IPv4 address in dotted decimal format—for example, "192.168.5.21". - //- An IPv6 address enclosed in square brackets—for example, "[2001:0DB8:ABCD:0012::F1]". - //- A hostname—for example, "example.com". + // - An IPv4 address in dotted decimal format—for example, "192.168.5.21". + // - An IPv6 address enclosed in square brackets—for example, "[2001:0DB8:ABCD:0012::F1]". + // - A hostname—for example, "example.com". // // The port is separated by a colon. It must be non-empty, with a decimal number // in the range of 0-65535, inclusive. bool host_and_port = 32 [ (predefined).cel = { id: "string.host_and_port" - message: "value must be a valid host (hostname or IP address) and port pair" + message: "must be a valid host (hostname or IP address) and port pair" expression: "!rules.host_and_port || this == '' || this.isHostAndPort(true)" }, (predefined).cel = { @@ -3711,14 +3711,14 @@ message StringRules { // // ```proto // message MyString { - // // value must be a valid ULID + // // must be a valid ULID // string value = 1 [(buf.validate.field).string.ulid = true]; // } // ``` bool ulid = 35 [ (predefined).cel = { id: "string.ulid" - message: "value must be a valid ULID" + message: "must be a valid ULID" expression: "!rules.ulid || this == '' || this.matches('^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$')" }, (predefined).cel = { @@ -3728,13 +3728,87 @@ message StringRules { } ]; + // `protobuf_fqn` specifies that the field value must be a valid fully-qualified + // Protobuf name as defined by the [Protobuf Language Specification](https://protobuf.com/docs/language-spec). + // + // A fully-qualified Protobuf name is a dot-separated list of Protobuf identifiers, + // where each identifier starts with a letter or underscore and is followed by zero or + // more letters, underscores, or digits. + // + // Examples: "buf.validate", "google.protobuf.Timestamp", "my_package.MyMessage". + // + // Note: historically, fully-qualified Protobuf names were represented with a leading + // dot (for example, ".buf.validate.StringRules"). Modern Protobuf does not use the + // leading dot, and most fully-qualified names are represented without it. Use + // `protobuf_dot_fqn` if a leading dot is required. + // + // If the field value isn't a valid fully-qualified Protobuf name, an error message + // will be generated. + // + // ```proto + // message MyString { + // // value must be a valid fully-qualified Protobuf name + // string value = 1 [(buf.validate.field).string.protobuf_fqn = true]; + // } + // ``` + bool protobuf_fqn = 37 [ + (predefined).cel = { + id: "string.protobuf_fqn" + message: "must be a valid fully-qualified Protobuf name" + expression: "!rules.protobuf_fqn || this == '' || this.matches('^[A-Za-z_][A-Za-z_0-9]*(\\\\.[A-Za-z_][A-Za-z_0-9]*)*$')" + }, + (predefined).cel = { + id: "string.protobuf_fqn_empty" + message: "value is empty, which is not a valid fully-qualified Protobuf name" + expression: "!rules.protobuf_fqn || this != ''" + } + ]; + + // `protobuf_dot_fqn` specifies that the field value must be a valid fully-qualified + // Protobuf name with a leading dot, as defined by the + // [Protobuf Language Specification](https://protobuf.com/docs/language-spec). + // + // A fully-qualified Protobuf name with a leading dot is a dot followed by a + // dot-separated list of Protobuf identifiers, where each identifier starts with a + // letter or underscore and is followed by zero or more letters, underscores, or + // digits. + // + // Examples: ".buf.validate", ".google.protobuf.Timestamp", ".my_package.MyMessage". + // + // Note: this is the historical representation of fully-qualified Protobuf names, + // where a leading dot denotes an absolute reference. Modern Protobuf does not use + // the leading dot, and most fully-qualified names are represented without it. Most + // users will want to use `protobuf_fqn` instead. + // + // If the field value isn't a valid fully-qualified Protobuf name with a leading dot, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid fully-qualified Protobuf name with a leading dot + // string value = 1 [(buf.validate.field).string.protobuf_dot_fqn = true]; + // } + // ``` + bool protobuf_dot_fqn = 38 [ + (predefined).cel = { + id: "string.protobuf_dot_fqn" + message: "must be a valid fully-qualified Protobuf name with a leading dot" + expression: "!rules.protobuf_dot_fqn || this == '' || this.matches('^\\\\.[A-Za-z_][A-Za-z_0-9]*(\\\\.[A-Za-z_][A-Za-z_0-9]*)*$')" + }, + (predefined).cel = { + id: "string.protobuf_dot_fqn_empty" + message: "value is empty, which is not a valid fully-qualified Protobuf name with a leading dot" + expression: "!rules.protobuf_dot_fqn || this != ''" + } + ]; + // `well_known_regex` specifies a common well-known pattern // defined as a regex. If the field value doesn't match the well-known // regex, an error message will be generated. // // ```proto // message MyString { - // // value must be a valid HTTP header value + // // must be a valid HTTP header value // string value = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_VALUE]; // } // ``` @@ -3751,7 +3825,7 @@ message StringRules { KnownRegex well_known_regex = 24 [ (predefined).cel = { id: "string.well_known_regex.header_name" - message: "value must be a valid HTTP header name" + message: "must be a valid HTTP header name" expression: "rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?" "'^:?[0-9a-zA-Z!#$%&\\'*+-.^_|~\\x60]+$' :" @@ -3764,7 +3838,7 @@ message StringRules { }, (predefined).cel = { id: "string.well_known_regex.header_value" - message: "value must be a valid HTTP header value" + message: "must be a valid HTTP header value" expression: "rules.well_known_regex != 2 || this.matches(!has(rules.strict) || rules.strict ?" "'^[^\\u0000-\\u0008\\u000A-\\u001F\\u007F]*$' :" @@ -3829,13 +3903,13 @@ message BytesRules { // // ```proto // message MyBytes { - // // value must be "\x01\x02\x03\x04" + // // must be "\x01\x02\x03\x04" // bytes value = 1 [(buf.validate.field).bytes.const = "\x01\x02\x03\x04"]; // } // ``` optional bytes const = 1 [(predefined).cel = { id: "bytes.const" - expression: "this != getField(rules, 'const') ? 'value must be %x'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must be %x'.format([getField(rules, 'const')]) : ''" }]; // `len` requires the field value to have the specified length in bytes. @@ -3849,7 +3923,7 @@ message BytesRules { // ``` optional uint64 len = 13 [(predefined).cel = { id: "bytes.len" - expression: "uint(this.size()) != rules.len ? 'value length must be %s bytes'.format([rules.len]) : ''" + expression: "uint(this.size()) != rules.len ? 'must be %s bytes'.format([rules.len]) : ''" }]; // `min_len` requires the field value to have at least the specified minimum @@ -3864,7 +3938,7 @@ message BytesRules { // ``` optional uint64 min_len = 2 [(predefined).cel = { id: "bytes.min_len" - expression: "uint(this.size()) < rules.min_len ? 'value length must be at least %s bytes'.format([rules.min_len]) : ''" + expression: "uint(this.size()) < rules.min_len ? 'must be at least %s bytes'.format([rules.min_len]) : ''" }]; // `max_len` requires the field value to have at most the specified maximum @@ -3873,13 +3947,13 @@ message BytesRules { // // ```proto // message MyBytes { - // // value must be at most 6 bytes. + // // must be at most 6 bytes. // optional bytes value = 1 [(buf.validate.field).bytes.max_len = 6]; // } // ``` optional uint64 max_len = 3 [(predefined).cel = { id: "bytes.max_len" - expression: "uint(this.size()) > rules.max_len ? 'value must be at most %s bytes'.format([rules.max_len]) : ''" + expression: "uint(this.size()) > rules.max_len ? 'must be at most %s bytes'.format([rules.max_len]) : ''" }]; // `pattern` requires the field value to match the specified regular @@ -3896,7 +3970,7 @@ message BytesRules { // ``` optional string pattern = 4 [(predefined).cel = { id: "bytes.pattern" - expression: "!string(this).matches(rules.pattern) ? 'value must match regex pattern `%s`'.format([rules.pattern]) : ''" + expression: "!string(this).matches(rules.pattern) ? 'must match regex pattern `%s`'.format([rules.pattern]) : ''" }]; // `prefix` requires the field value to have the specified bytes at the @@ -3911,7 +3985,7 @@ message BytesRules { // ``` optional bytes prefix = 5 [(predefined).cel = { id: "bytes.prefix" - expression: "!this.startsWith(rules.prefix) ? 'value does not have prefix %x'.format([rules.prefix]) : ''" + expression: "!this.startsWith(rules.prefix) ? 'does not have prefix %x'.format([rules.prefix]) : ''" }]; // `suffix` requires the field value to have the specified bytes at the end @@ -3926,7 +4000,7 @@ message BytesRules { // ``` optional bytes suffix = 6 [(predefined).cel = { id: "bytes.suffix" - expression: "!this.endsWith(rules.suffix) ? 'value does not have suffix %x'.format([rules.suffix]) : ''" + expression: "!this.endsWith(rules.suffix) ? 'does not have suffix %x'.format([rules.suffix]) : ''" }]; // `contains` requires the field value to have the specified bytes anywhere in @@ -3941,7 +4015,7 @@ message BytesRules { // ``` optional bytes contains = 7 [(predefined).cel = { id: "bytes.contains" - expression: "!this.contains(rules.contains) ? 'value does not contain %x'.format([rules.contains]) : ''" + expression: "!this.contains(rules.contains) ? 'does not contain %x'.format([rules.contains]) : ''" }]; // `in` requires the field value to be equal to one of the specified @@ -3956,7 +4030,7 @@ message BytesRules { // ``` repeated bytes in = 8 [(predefined).cel = { id: "bytes.in" - expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to be not equal to any of the specified @@ -3972,7 +4046,7 @@ message BytesRules { // ``` repeated bytes not_in = 9 [(predefined).cel = { id: "bytes.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // WellKnown rules provide advanced rules against common byte @@ -3983,14 +4057,14 @@ message BytesRules { // // ```proto // message MyBytes { - // // value must be a valid IP address + // // must be a valid IP address // optional bytes value = 1 [(buf.validate.field).bytes.ip = true]; // } // ``` bool ip = 10 [ (predefined).cel = { id: "bytes.ip" - message: "value must be a valid IP address" + message: "must be a valid IP address" expression: "!rules.ip || this.size() == 0 || this.size() == 4 || this.size() == 16" }, (predefined).cel = { @@ -4005,14 +4079,14 @@ message BytesRules { // // ```proto // message MyBytes { - // // value must be a valid IPv4 address + // // must be a valid IPv4 address // optional bytes value = 1 [(buf.validate.field).bytes.ipv4 = true]; // } // ``` bool ipv4 = 11 [ (predefined).cel = { id: "bytes.ipv4" - message: "value must be a valid IPv4 address" + message: "must be a valid IPv4 address" expression: "!rules.ipv4 || this.size() == 0 || this.size() == 4" }, (predefined).cel = { @@ -4026,14 +4100,14 @@ message BytesRules { // If the field value doesn't meet this rule, an error message is generated. // ```proto // message MyBytes { - // // value must be a valid IPv6 address + // // must be a valid IPv6 address // optional bytes value = 1 [(buf.validate.field).bytes.ipv6 = true]; // } // ``` bool ipv6 = 12 [ (predefined).cel = { id: "bytes.ipv6" - message: "value must be a valid IPv6 address" + message: "must be a valid IPv6 address" expression: "!rules.ipv6 || this.size() == 0 || this.size() == 16" }, (predefined).cel = { @@ -4043,22 +4117,21 @@ message BytesRules { } ]; - // `uuid` ensures that the field `value` encodes the 128-bit UUID data as - // defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). - // The field must contain exactly 16 bytes - // representing the UUID. If the field value isn't a valid UUID, an error - // message will be generated. + // `uuid` ensures that the field value encodes 128-bit UUID data as defined + // by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). + // The field must contain exactly 16 bytes representing the UUID. If the + // field value isn't a valid UUID, an error message will be generated. // // ```proto // message MyBytes { - // // value must be a valid UUID + // // must be a valid UUID // optional bytes value = 1 [(buf.validate.field).bytes.uuid = true]; // } // ``` bool uuid = 15 [ (predefined).cel = { id: "bytes.uuid" - message: "value must be a valid UUID" + message: "must be a valid UUID" expression: "!rules.uuid || this.size() == 0 || this.size() == 16" }, (predefined).cel = { @@ -4111,7 +4184,7 @@ message EnumRules { // ``` optional int32 const = 1 [(predefined).cel = { id: "enum.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; // `defined_only` requires the field value to be one of the defined values for @@ -4132,8 +4205,8 @@ message EnumRules { optional bool defined_only = 2; // `in` requires the field value to be equal to one of the - //specified enum values. If the field value doesn't match any of the - //specified values, an error message is generated. + // specified enum values. If the field value doesn't match any of the + // specified values, an error message is generated. // // ```proto // enum MyEnum { @@ -4149,11 +4222,11 @@ message EnumRules { // ``` repeated int32 in = 3 [(predefined).cel = { id: "enum.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to be not equal to any of the - //specified enum values. If the field value matches one of the specified + // specified enum values. If the field value matches one of the specified // values, an error message is generated. // // ```proto @@ -4170,7 +4243,7 @@ message EnumRules { // ``` repeated int32 not_in = 4 [(predefined).cel = { id: "enum.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -4215,7 +4288,7 @@ message RepeatedRules { // ``` optional uint64 min_items = 1 [(predefined).cel = { id: "repeated.min_items" - expression: "uint(this.size()) < rules.min_items ? 'value must contain at least %d item(s)'.format([rules.min_items]) : ''" + expression: "uint(this.size()) < rules.min_items ? 'must contain at least %d item(s)'.format([rules.min_items]) : ''" }]; // `max_items` denotes that this field must not exceed a @@ -4231,7 +4304,7 @@ message RepeatedRules { // ``` optional uint64 max_items = 2 [(predefined).cel = { id: "repeated.max_items" - expression: "uint(this.size()) > rules.max_items ? 'value must contain no more than %s item(s)'.format([rules.max_items]) : ''" + expression: "uint(this.size()) > rules.max_items ? 'must contain no more than %s item(s)'.format([rules.max_items]) : ''" }]; // `unique` indicates that all elements in this field must @@ -4350,7 +4423,7 @@ message MapRules { // AnyRules describe rules applied exclusively to the `google.protobuf.Any` well-known type. message AnyRules { // `in` requires the field's `type_url` to be equal to one of the - //specified values. If it doesn't match any of the specified values, an error + // specified values. If it doesn't match any of the specified values, an error // message is generated. // // ```proto @@ -4363,7 +4436,7 @@ message AnyRules { // ``` repeated string in = 2; - // requires the field's type_url to be not equal to any of the specified values. If it matches any of the specified values, an error message is generated. + // `not_in` requires the field's type_url to be not equal to any of the specified values. If it matches any of the specified values, an error message is generated. // // ```proto // message MyAny { @@ -4390,7 +4463,7 @@ message DurationRules { // ``` optional google.protobuf.Duration const = 2 [(predefined).cel = { id: "duration.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` stipulates that the field must be less than the specified value of the `google.protobuf.Duration` type, @@ -4399,7 +4472,7 @@ message DurationRules { // // ```proto // message MyDuration { - // // value must be less than 5s + // // must be less than 5s // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = "5s"]; // } // ``` @@ -4407,7 +4480,7 @@ message DurationRules { id: "duration.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; // `lte` indicates that the field must be less than or equal to the specified @@ -4416,7 +4489,7 @@ message DurationRules { // // ```proto // message MyDuration { - // // value must be less than or equal to 10s + // // must be less than or equal to 10s // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lte = "10s"]; // } // ``` @@ -4424,7 +4497,7 @@ message DurationRules { id: "duration.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; } oneof greater_than { @@ -4451,31 +4524,31 @@ message DurationRules { id: "duration.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "duration.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "duration.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "duration.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "duration.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -4502,31 +4575,31 @@ message DurationRules { id: "duration.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "duration.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "duration.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "duration.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "duration.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; } @@ -4537,13 +4610,13 @@ message DurationRules { // // ```proto // message MyDuration { - // // value must be in list [1s, 2s, 3s] + // // must be in list [1s, 2s, 3s] // google.protobuf.Duration value = 1 [(buf.validate.field).duration.in = ["1s", "2s", "3s"]]; // } // ``` repeated google.protobuf.Duration in = 7 [(predefined).cel = { id: "duration.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` denotes that the field must not be equal to @@ -4559,7 +4632,7 @@ message DurationRules { // ``` repeated google.protobuf.Duration not_in = 8 [(predefined).cel = { id: "duration.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + expression: "this in rules.not_in ? 'must not be in list %s'.format([rules.not_in]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -4601,7 +4674,7 @@ message FieldMaskRules { // ``` optional google.protobuf.FieldMask const = 1 [(predefined).cel = { id: "field_mask.const" - expression: "this.paths != getField(rules, 'const').paths ? 'value must equal paths %s'.format([getField(rules, 'const').paths]) : ''" + expression: "this.paths != getField(rules, 'const').paths ? 'must equal paths %s'.format([getField(rules, 'const').paths]) : ''" }]; // `in` requires the field value to only contain paths matching specified @@ -4620,7 +4693,7 @@ message FieldMaskRules { // ``` repeated string in = 2 [(predefined).cel = { id: "field_mask.in" - expression: "!this.paths.all(p, p in getField(rules, 'in') || getField(rules, 'in').exists(f, p.startsWith(f+'.'))) ? 'value must only contain paths in %s'.format([getField(rules, 'in')]) : ''" + expression: "!this.paths.all(p, p in getField(rules, 'in') || getField(rules, 'in').exists(f, p.startsWith(f+'.'))) ? 'must only contain paths in %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not contain paths matching specified @@ -4639,7 +4712,7 @@ message FieldMaskRules { // ``` repeated string not_in = 3 [(predefined).cel = { id: "field_mask.not_in" - expression: "!this.paths.all(p, !(p in getField(rules, 'not_in') || getField(rules, 'not_in').exists(f, p.startsWith(f+'.')))) ? 'value must not contain any paths in %s'.format([getField(rules, 'not_in')]) : ''" + expression: "!this.paths.all(p, !(p in getField(rules, 'not_in') || getField(rules, 'not_in').exists(f, p.startsWith(f+'.')))) ? 'must not contain any paths in %s'.format([getField(rules, 'not_in')]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD @@ -4677,25 +4750,25 @@ message TimestampRules { // ``` optional google.protobuf.Timestamp const = 2 [(predefined).cel = { id: "timestamp.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + expression: "this != getField(rules, 'const') ? 'must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { - // requires the duration field value to be less than the specified value (field < value). If the field value doesn't meet the required conditions, an error message is generated. + // `lt` requires the timestamp field value to be less than the specified value (field < value). If the field value doesn't meet the required conditions, an error message is generated. // // ```proto - // message MyDuration { - // // duration must be less than 'P3D' [duration.lt] - // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = { seconds: 259200 }]; + // message MyTimestamp { + // // timestamp must be less than '2023-01-01T00:00:00Z' [timestamp.lt] + // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lt = { seconds: 1672444800 }]; // } // ``` google.protobuf.Timestamp lt = 3 [(predefined).cel = { id: "timestamp.lt" expression: "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" + "? 'must be less than %s'.format([rules.lt]) : ''" }]; - // requires the timestamp field value to be less than or equal to the specified value (field <= value). If the field value doesn't meet the required conditions, an error message is generated. + // `lte` requires the timestamp field value to be less than or equal to the specified value (field <= value). If the field value doesn't meet the required conditions, an error message is generated. // // ```proto // message MyTimestamp { @@ -4707,20 +4780,20 @@ message TimestampRules { id: "timestamp.lte" expression: "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + "? 'must be less than or equal to %s'.format([rules.lte]) : ''" }]; // `lt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be less than the current time. `lt_now` can only be used with the `within` rule. // // ```proto // message MyTimestamp { - // // value must be less than now + // // must be less than now // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.lt_now = true]; // } // ``` bool lt_now = 7 [(predefined).cel = { id: "timestamp.lt_now" - expression: "(rules.lt_now && this > now) ? 'value must be less than now' : ''" + expression: "(rules.lt_now && this > now) ? 'must be less than now' : ''" }]; } oneof greater_than { @@ -4747,31 +4820,31 @@ message TimestampRules { id: "timestamp.gt" expression: "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" + "? 'must be greater than %s'.format([rules.gt]) : ''" }, (predefined).cel = { id: "timestamp.gt_lt" expression: "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "timestamp.gt_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + "? 'must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, (predefined).cel = { id: "timestamp.gt_lte" expression: "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, (predefined).cel = { id: "timestamp.gt_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + "? 'must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" } ]; @@ -4798,31 +4871,31 @@ message TimestampRules { id: "timestamp.gte" expression: "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + "? 'must be greater than or equal to %s'.format([rules.gte]) : ''" }, (predefined).cel = { id: "timestamp.gte_lt" expression: "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "timestamp.gte_lt_exclusive" expression: "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + "? 'must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, (predefined).cel = { id: "timestamp.gte_lte" expression: "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, (predefined).cel = { id: "timestamp.gte_lte_exclusive" expression: "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + "? 'must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" } ]; @@ -4830,13 +4903,13 @@ message TimestampRules { // // ```proto // message MyTimestamp { - // // value must be greater than now + // // must be greater than now // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.gt_now = true]; // } // ``` bool gt_now = 8 [(predefined).cel = { id: "timestamp.gt_now" - expression: "(rules.gt_now && this < now) ? 'value must be greater than now' : ''" + expression: "(rules.gt_now && this < now) ? 'must be greater than now' : ''" }]; } @@ -4844,13 +4917,13 @@ message TimestampRules { // // ```proto // message MyTimestamp { - // // value must be within 1 hour of now + // // must be within 1 hour of now // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.within = {seconds: 3600}]; // } // ``` optional google.protobuf.Duration within = 9 [(predefined).cel = { id: "timestamp.within" - expression: "this < now-rules.within || this > now+rules.within ? 'value must be within %s of now'.format([rules.within]) : ''" + expression: "this < now-rules.within || this > now+rules.within ? 'must be within %s of now'.format([rules.within]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD diff --git a/internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto b/internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto index 5d7b3ebc..661a3c44 100644 --- a/internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto +++ b/internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto @@ -7,12 +7,12 @@ package tableau; import "google/protobuf/descriptor.proto"; +option csharp_namespace = "Tableau.Protobuf.Tableau"; option go_package = "github.com/tableauio/tableau/proto/tableaupb"; -option java_package = "com.tableau.protobuf"; -option java_outer_classname = "TableauProto"; option java_multiple_files = true; +option java_outer_classname = "TableauProto"; +option java_package = "com.tableau.protobuf"; option objc_class_prefix = "TPB"; -option csharp_namespace = "Tableau.Protobuf.Tableau"; // Option field numbers must be in the range 50000-99999. This range // is reserved for internal use within individual organizations. @@ -44,29 +44,29 @@ extend google.protobuf.OneofOptions { } message EnumOptions { - string name = 1; // Worksheet name. - string note = 2; // Enum type note. Maybe in another language (Chinese). + string name = 1; // Worksheet name. + string note = 2; // Enum type note. Maybe in another language (Chinese). } message EnumValueOptions { - string name = 1; // Enum value alias. - string note = 2; // Enum value note. Maybe in another language (Chinese). + string name = 1; // Enum value alias. + string note = 2; // Enum value note. Maybe in another language (Chinese). } message StructOptions { - string name = 1; // Worksheet name. - string note = 2; // Struct type note. Maybe in another language (Chinese). + string name = 1; // Worksheet name. + string note = 2; // Struct type note. Maybe in another language (Chinese). } message UnionOptions { - string name = 1; // Worksheet name. - string note = 2; // Oneof note, maybe in another language (Chinese). + string name = 1; // Worksheet name. + string note = 2; // Oneof note, maybe in another language (Chinese). } message OneofOptions { - string name = 1; // Oneof alias. NOT USED yet. - string note = 2; // Oneof note, maybe in another language (Chinese). - string field = 3; // Field name. + string name = 1; // Oneof alias. NOT USED yet. + string note = 2; // Oneof note, maybe in another language (Chinese). + string field = 3; // Field name. } message WorkbookOptions { @@ -246,11 +246,11 @@ message WorksheetOptions { // Different kvs must be seperated by ',' and one key value must be seperated // by ':'. If one key doesn't exist in map, it means that this loader option // is supported in all languages. Valid values are all combinations of "cpp", - // "go" and "csharp" with ' ' as seperator. + // "go", "csharp" and "ts" with ' ' as seperator. // // Examples: - // - OrderedMap:cpp,Index:cpp go // ordered map supported in cpp, index - // supported in cpp and go + // - OrderedMap:cpp,Index:cpp go ts // ordered map supported in cpp, index + // supported in cpp, go and ts // - OrderedMap:cpp // ordered map supported in cpp, index supported in all // languages map lang_options = 52; @@ -261,13 +261,13 @@ message WorksheetOptions { } message FieldOptions { - string name = 1; // Scalar type's variable name or composite type's variable name (prefix). - string note = 2; // Field note. Maybe in another language (Chinese). - string key = 3; // Only set when this field type is map or keyed-list. - Layout layout = 4; // For map/list types with cardinality. Default: LAYOUT_DEFAULT. - Span span = 5; // For list element or map value types. Default: SPAN_CROSS_CELL. + string name = 1; // Scalar type's variable name or composite type's variable name (prefix). + string note = 2; // Field note. Maybe in another language (Chinese). + string key = 3; // Only set when this field type is map or keyed-list. + Layout layout = 4; // For map/list types with cardinality. Default: LAYOUT_DEFAULT. + Span span = 5; // For list element or map value types. Default: SPAN_CROSS_CELL. - FieldProp prop = 15; // Property of field. + FieldProp prop = 15; // Property of field. } message FieldProp { @@ -367,6 +367,25 @@ message FieldProp { // // See https://github.com/bufbuild/protovalidate. string validate_message = 20; + // If true, this incell map/list field aggregates elements from repeated + // visits to the same enclosing message into a single combined collection. + // Repeated visits occur when multiple rows or columns parse into the same + // message, e.g.: + // - vertical map/keyed-list with same key across rows + // - horizontal map with same key across columns + // - vertical/horizontal list spanning multiple rows/columns (sibling + // incell fields revisited per row or column) + // + // Without aggregate (default): all visits must produce the identical incell + // value, otherwise error E2023 is reported. + // + // With aggregate: + // - incell map: merges entries from each visit; duplicate map keys across + // visits report error E2005. + // - incell list: appends elements from each visit unconditionally. + // - incell keyed-list: appends elements from each visit; duplicate keys + // across visits report error E2028. + bool aggregate = 21; } // Layout of list and map. @@ -377,9 +396,9 @@ enum Layout { // - horizontal for struct list // - incell for scalar list LAYOUT_DEFAULT = 0; - LAYOUT_VERTICAL = 1; // Vertical - LAYOUT_HORIZONTAL = 2; // Horizontal - LAYOUT_INCELL = 3; // Incell + LAYOUT_VERTICAL = 1; // Vertical + LAYOUT_HORIZONTAL = 2; // Horizontal + LAYOUT_INCELL = 3; // Incell } // Field data span of scalar and struct. @@ -388,32 +407,32 @@ enum Span { // - inner cell for scalar type: bool, string, bytes, number, and enum. // - cross cell for struct type: map-value, list-element, and struct-field. SPAN_DEFAULT = 0; - SPAN_CROSS_CELL = 1; // The field data spans across multiple cells. - SPAN_INNER_CELL = 2; // The field data spans inside one cell. + SPAN_CROSS_CELL = 1; // The field data spans across multiple cells. + SPAN_INNER_CELL = 2; // The field data spans inside one cell. } // Sheet mode. enum Mode { - MODE_DEFAULT = 0; // Default mode. - MODE_ENUM_TYPE = 1; // Enum type: single definition in a sheet. - MODE_ENUM_TYPE_MULTI = 2; // Enum type: multiple definitions in a sheet. - MODE_STRUCT_TYPE = 3; // Struct type: single definition in a sheet. - MODE_STRUCT_TYPE_MULTI = 4; // Struct type: multiple definitions in a sheet. - MODE_UNION_TYPE = 5; // Union type: single definition in a sheet. - MODE_UNION_TYPE_MULTI = 6; // Union type: multiple definitions in a sheet. + MODE_DEFAULT = 0; // Default mode. + MODE_ENUM_TYPE = 1; // Enum type: single definition in a sheet. + MODE_ENUM_TYPE_MULTI = 2; // Enum type: multiple definitions in a sheet. + MODE_STRUCT_TYPE = 3; // Struct type: single definition in a sheet. + MODE_STRUCT_TYPE_MULTI = 4; // Struct type: multiple definitions in a sheet. + MODE_UNION_TYPE = 5; // Union type: single definition in a sheet. + MODE_UNION_TYPE_MULTI = 6; // Union type: multiple definitions in a sheet. // UE DataTable references: // - https://dev.epicgames.com/documentation/en-us/unreal-engine/data-driven-gameplay-elements-in-unreal-engine // - https://dev.epicgames.com/documentation/en-us/unreal-engine/BlueprintAPI/EditorScripting/DataTable - MODE_UE_CSV = 10; // TODO: CSV format of UE DataTable. - MODE_UE_JSON = 11; // TODO: JSON format of UE DataTable. + MODE_UE_CSV = 10; // TODO: CSV format of UE DataTable. + MODE_UE_JSON = 11; // TODO: JSON format of UE DataTable. } // Cell data form. enum Form { - FORM_DEFAULT = 0; // Default form which confgen parser will parse. - FORM_TEXT = 1; // Refer: https://developers.google.com/protocol-buffers/docs/text-format-spec - FORM_JSON = 2; // Refer: https://developers.google.com/protocol-buffers/docs/proto3#json + FORM_DEFAULT = 0; // Default form which confgen parser will parse. + FORM_TEXT = 1; // Refer: https://developers.google.com/protocol-buffers/docs/text-format-spec + FORM_JSON = 2; // Refer: https://developers.google.com/protocol-buffers/docs/proto3#json } // Patch type for both sheet-level and field-level. @@ -443,8 +462,8 @@ enum Patch { // Field value order. enum Order { ORDER_NONE = 0; - ORDER_ASC = 1; // ascending: >= - ORDER_DESC = 2; // descending: <= - ORDER_STRICTLY_ASC = 3; // strictly ascending: > - ORDER_STRICTLY_DESC = 4; // strictly descending: < -} \ No newline at end of file + ORDER_ASC = 1; // ascending: >= + ORDER_DESC = 2; // descending: <= + ORDER_STRICTLY_ASC = 3; // strictly ascending: > + ORDER_STRICTLY_DESC = 4; // strictly descending: < +} diff --git a/internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto b/internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto index ee37b390..7c432c97 100644 --- a/internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto +++ b/internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto @@ -5,15 +5,15 @@ syntax = "proto3"; package tableau; +import "tableau/protobuf/tableau.proto"; + option cc_enable_arenas = true; +option csharp_namespace = "Tableau.Protobuf.Tableau"; option go_package = "github.com/tableauio/tableau/proto/tableaupb"; -option java_package = "com.tableau.protobuf"; -option java_outer_classname = "TableauProto"; option java_multiple_files = true; +option java_outer_classname = "TableauProto"; +option java_package = "com.tableau.protobuf"; option objc_class_prefix = "TPB"; -option csharp_namespace = "Tableau.Protobuf.Tableau"; - -import "tableau/protobuf/tableau.proto"; // Supported formats: // - N%: percentage, e.g.: 10% @@ -22,8 +22,8 @@ import "tableau/protobuf/tableau.proto"; // - N/D: simple fraction, e.g.: 3/4 // - N: only numerator, e.g.: 3 is same to 3/1 message Fraction { - int32 num = 1; // numerator - int32 den = 2; // denominator + int32 num = 1; // numerator + int32 den = 2; // denominator } // Format: @@ -33,12 +33,12 @@ message Comparator { Fraction value = 2; enum Sign { - SIGN_EQUAL = 0; // == - SIGN_NOT_EQUAL = 1; // != - SIGN_LESS = 2; // < - SIGN_LESS_OR_EQUAL = 3; // <= - SIGN_GREATER = 4; // > - SIGN_GREATER_OR_EQUAL = 5; // >= + SIGN_EQUAL = 0; // == + SIGN_NOT_EQUAL = 1; // != + SIGN_LESS = 2; // < + SIGN_LESS_OR_EQUAL = 3; // <= + SIGN_GREATER = 4; // > + SIGN_GREATER_OR_EQUAL = 5; // >= } } @@ -50,49 +50,49 @@ message Comparator { // A 2D vector using float coordinates. // See https://docs.godotengine.org/en/stable/classes/class_vector2.html message Vector2 { - float x = 1 [(tableau.field) = { name: "X" }]; - float y = 2 [(tableau.field) = { name: "Y" }]; + float x = 1 [(tableau.field) = {name: "X"}]; + float y = 2 [(tableau.field) = {name: "Y"}]; } // A 3D vector using float coordinates. // See https://docs.godotengine.org/en/stable/classes/class_vector3.html message Vector3 { - float x = 1 [(tableau.field) = { name: "X" }]; - float y = 2 [(tableau.field) = { name: "Y" }]; - float z = 3 [(tableau.field) = { name: "Z" }]; + float x = 1 [(tableau.field) = {name: "X"}]; + float y = 2 [(tableau.field) = {name: "Y"}]; + float z = 3 [(tableau.field) = {name: "Z"}]; } // A 4D vector using float coordinates. // See https://docs.godotengine.org/en/stable/classes/class_vector4.html message Vector4 { - float x = 1 [(tableau.field) = { name: "X" }]; - float y = 2 [(tableau.field) = { name: "Y" }]; - float z = 3 [(tableau.field) = { name: "Z" }]; - float w = 4 [(tableau.field) = { name: "W" }]; + float x = 1 [(tableau.field) = {name: "X"}]; + float y = 2 [(tableau.field) = {name: "Y"}]; + float z = 3 [(tableau.field) = {name: "Z"}]; + float w = 4 [(tableau.field) = {name: "W"}]; } // A 2D vector using int32 coordinates. // See https://docs.godotengine.org/en/stable/classes/class_vector2i.html message Vector2i { - int32 x = 1 [(tableau.field) = { name: "X" }]; - int32 y = 2 [(tableau.field) = { name: "Y" }]; + int32 x = 1 [(tableau.field) = {name: "X"}]; + int32 y = 2 [(tableau.field) = {name: "Y"}]; } // A 3D vector using int32 coordinates. // See https://docs.godotengine.org/en/stable/classes/class_vector3i.html message Vector3i { - int32 x = 1 [(tableau.field) = { name: "X" }]; - int32 y = 2 [(tableau.field) = { name: "Y" }]; - int32 z = 3 [(tableau.field) = { name: "Z" }]; + int32 x = 1 [(tableau.field) = {name: "X"}]; + int32 y = 2 [(tableau.field) = {name: "Y"}]; + int32 z = 3 [(tableau.field) = {name: "Z"}]; } // A 4D vector using int32 coordinates. // See https://docs.godotengine.org/en/stable/classes/class_vector4i.html message Vector4i { - int32 x = 1 [(tableau.field) = { name: "X" }]; - int32 y = 2 [(tableau.field) = { name: "Y" }]; - int32 z = 3 [(tableau.field) = { name: "Z" }]; - int32 w = 4 [(tableau.field) = { name: "W" }]; + int32 x = 1 [(tableau.field) = {name: "X"}]; + int32 y = 2 [(tableau.field) = {name: "Y"}]; + int32 z = 3 [(tableau.field) = {name: "Z"}]; + int32 w = 4 [(tableau.field) = {name: "W"}]; } // Version number in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation). @@ -106,10 +106,10 @@ message Vector4i { // // Default pattern: "255.255.255". message Version { - string str = 1; // Version in string form. - uint64 val = 2; // Version in integer form. - uint32 major = 3; // Major version number. - uint32 minor = 4; // Minor version number. - uint32 patch = 5; // Patch version number. - repeated uint32 others = 6; // Other version numbers, such as build number, resource version, and so on. -} \ No newline at end of file + string str = 1; // Version in string form. + uint64 val = 2; // Version in integer form. + uint32 major = 3; // Major version number. + uint32 minor = 4; // Minor version number. + uint32 patch = 5; // Patch version number. + repeated uint32 others = 6; // Other version numbers, such as build number, resource version, and so on. +} From 017b7ce6e9b402328197d04e1ea94621692ccd24 Mon Sep 17 00:00:00 2001 From: Kybxd <627940450@qq.com> Date: Thu, 9 Jul 2026 15:56:41 +0800 Subject: [PATCH 4/4] protoc: dedupe embedded tableau.proto/wellknown.proto via proto/tableau/protobuf.FS --- internal/x/xproto/protoc/embed.go | 46 +- .../embedded/tableau/protobuf/tableau.proto | 469 ------------------ .../embedded/tableau/protobuf/wellknown.proto | 115 ----- internal/x/xproto/protoc/gen_embedded.sh | 18 +- proto/tableau/protobuf/embed.go | 15 + 5 files changed, 51 insertions(+), 612 deletions(-) delete mode 100644 internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto delete mode 100644 internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto create mode 100644 proto/tableau/protobuf/embed.go diff --git a/internal/x/xproto/protoc/embed.go b/internal/x/xproto/protoc/embed.go index aac20b85..4c528c3b 100644 --- a/internal/x/xproto/protoc/embed.go +++ b/internal/x/xproto/protoc/embed.go @@ -3,6 +3,9 @@ package protoc import ( "embed" "io/fs" + "strings" + + tableauprotobuf "github.com/tableauio/tableau/proto/tableau/protobuf" ) // Embedded .proto sources used as fallback dependencies for protocompile's @@ -11,10 +14,12 @@ import ( // FileDescriptors via protoreglistry.GlobalFiles like the stable Compiler did. // // We embed: -// - tableau/protobuf/*.proto (this repository's own schemas, copied from -// proto/tableau/protobuf/) -// - buf/validate/*.proto (the protovalidate schemas, exported from the buf -// module pinned in buf.lock) +// - tableau/protobuf/*.proto: this repository's own schemas, reused +// directly from [tableauprotobuf.FS] (proto/tableau/protobuf/) — no +// second copy, so it can never go stale. +// - buf/validate/*.proto: the protovalidate schemas, exported from the buf +// module pinned in buf.lock (checked into embedded/ below, since this +// repo has no local source for it). // // Standard imports (google/protobuf/*) are provided automatically by // [source.WKTs]. @@ -22,8 +27,8 @@ import ( // The contents under embedded/ ARE checked into version control so that // downstream consumers (e.g. `go install github.com/tableauio/tableau/cmd/ // tableauc@latest`) can build without running `go generate` or having `buf` -// installed. Run `go generate ./...` after editing proto/tableau/protobuf/ -// or bumping the protovalidate dep in buf.lock to refresh embedded/. +// installed. Run `go generate ./...` after bumping the protovalidate dep in +// buf.lock to refresh embedded/. // // Version pinning: `buf export ` does NOT consult the // workspace's buf.lock — that file only governs transitive resolution for @@ -37,17 +42,32 @@ import ( //go:generate ./gen_embedded.sh //go:embed embedded/buf/validate/validate.proto -//go:embed embedded/tableau/protobuf/tableau.proto -//go:embed embedded/tableau/protobuf/wellknown.proto -var embeddedProtos embed.FS +var embeddedBufValidate embed.FS -// embeddedFS returns the embedded.FS rooted at "embedded/" so that paths -// look like "buf/validate/validate.proto" or "tableau/protobuf/tableau.proto". +// embeddedFS returns an [fs.FS] that resolves paths like +// "buf/validate/validate.proto" (from the vendored buf export) and +// "tableau/protobuf/tableau.proto" (from [tableauprotobuf.FS], the single +// source of truth also used to build proto/tableaupb). func embeddedFS() fs.FS { - sub, err := fs.Sub(embeddedProtos, "embedded") + bufValidate, err := fs.Sub(embeddedBufValidate, "embedded") if err != nil { // Should never happen because the directory is hard-coded. panic(err) } - return sub + return &layeredFS{tableauProtobuf: tableauprotobuf.FS, bufValidate: bufValidate} +} + +// layeredFS routes "tableau/protobuf/*" reads to tableauProtobuf (stripping +// the prefix) and everything else to bufValidate. +type layeredFS struct { + tableauProtobuf fs.FS + bufValidate fs.FS +} + +// Open implements [fs.FS]. +func (l *layeredFS) Open(name string) (fs.File, error) { + if rest, ok := strings.CutPrefix(name, "tableau/protobuf/"); ok { + return l.tableauProtobuf.Open(rest) + } + return l.bufValidate.Open(name) } diff --git a/internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto b/internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto deleted file mode 100644 index 661a3c44..00000000 --- a/internal/x/xproto/protoc/embedded/tableau/protobuf/tableau.proto +++ /dev/null @@ -1,469 +0,0 @@ -// Protoconf - Tableau's data interchange format -// https://tableauio.github.io/ - -syntax = "proto3"; - -package tableau; - -import "google/protobuf/descriptor.proto"; - -option csharp_namespace = "Tableau.Protobuf.Tableau"; -option go_package = "github.com/tableauio/tableau/proto/tableaupb"; -option java_multiple_files = true; -option java_outer_classname = "TableauProto"; -option java_package = "com.tableau.protobuf"; -option objc_class_prefix = "TPB"; - -// Option field numbers must be in the range 50000-99999. This range -// is reserved for internal use within individual organizations. - -extend google.protobuf.FileOptions { - WorkbookOptions workbook = 50000; -} - -extend google.protobuf.MessageOptions { - WorksheetOptions worksheet = 50000; - StructOptions struct = 50001; - UnionOptions union = 50002; -} - -extend google.protobuf.FieldOptions { - FieldOptions field = 50000; -} - -extend google.protobuf.EnumOptions { - EnumOptions etype = 50000; -} - -extend google.protobuf.EnumValueOptions { - EnumValueOptions evalue = 50000; -} - -extend google.protobuf.OneofOptions { - optional OneofOptions oneof = 50000; -} - -message EnumOptions { - string name = 1; // Worksheet name. - string note = 2; // Enum type note. Maybe in another language (Chinese). -} - -message EnumValueOptions { - string name = 1; // Enum value alias. - string note = 2; // Enum value note. Maybe in another language (Chinese). -} - -message StructOptions { - string name = 1; // Worksheet name. - string note = 2; // Struct type note. Maybe in another language (Chinese). -} - -message UnionOptions { - string name = 1; // Worksheet name. - string note = 2; // Oneof note, maybe in another language (Chinese). -} - -message OneofOptions { - string name = 1; // Oneof alias. NOT USED yet. - string note = 2; // Oneof note, maybe in another language (Chinese). - string field = 3; // Field name. -} - -message WorkbookOptions { - // filename with path, e.g.: "relative/path/BookName.suffix" (slash path) - string name = 1; - // book alias without suffix, e.g.: "BookAlias" - string alias = 2; - // Exact row number of column name definition at a worksheet. - // - // Default: 1. - int32 namerow = 3; - // Exact row number of column type definition at a worksheet. - // - // Default: 2. - int32 typerow = 4; - // Exact row number of column note definition at a worksheet. - // - // Default: 3. - int32 noterow = 5; - // Start row number of data at a worksheet. - // - // Default: 4. - int32 datarow = 6; - // The line number of column name definition in a cell. 0 means - // the whole cell. - // - // Default: 0. - int32 nameline = 7; - // The line number of column type definition in a cell. 0 means - // the whole cell. - // - // Default: 0. - int32 typeline = 8; - // The line number of column note definition in a cell. 0 means - // the whole cell. - // - // Default: 0. - int32 noteline = 9; - // Sheet-level separator for separating: - // - incell list elements (scalar or struct). - // - incell map items. - // - // If set, it will overwrite global-level seq in options.ConfInputOption.Sep. - string sep = 10; - // Sheet-level subseparator for separating: - // - key-value pair of each incell map item. - // - struct fields of each incell struct list element. - // - // If set, it will overwrite global-level subseq in options.ConfInputOption.Subsep. - string subsep = 11; -} - -message WorksheetOptions { - // Worksheet name - string name = 1; - // Exact row number of column name definition at a worksheet. - // - // Default: 1. - int32 namerow = 2; - // Exact row number of column type definition at a worksheet. - // - // Default: 2. - int32 typerow = 3; - // Exact row number of column note definition at a worksheet. - // - // Default: 3. - int32 noterow = 4; - // Start row number of data at a worksheet. - // - // Default: 4. - int32 datarow = 5; - // The line number of column name definition in a cell. 0 means - // the whole cell. - // - // Default: 0. - int32 nameline = 6; - // The line number of column type definition in a cell. 0 means - // the whole cell. - // - // Default: 0. - int32 typeline = 7; - // The line number of column note definition in a cell. 0 means - // the whole cell. - // - // Default: 0. - int32 noteline = 8; - // Sheet-level separator for separating: - // - incell list elements (scalar or struct). - // - incell map items. - // - // If set, it will overwrite global-level seq in options.ConfInputOption.Sep. - string sep = 9; - // Sheet-level subseparator for separating: - // - key-value pair of each incell map item. - // - struct fields of each incell struct list element. - // - // If set, it will overwrite global-level subseq in options.ConfInputOption.Subsep. - string subsep = 10; - // Nested naming of the namerow. - bool nested = 11; - // Interchange the rows and columns of worksheet. - bool transpose = 12; - // Labels are key/value pairs that are attached to sheet. - // Labels can be used to organize and to select subsets of sheets. - // For example: - // - "app:gamesvr,patch:merge" indicates app is gamesvr and patch is true. - // - "app:*" indicates all apps. - // - // This concept is much like it is in k8s, see - // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/. - map labels = 13; - // Merger merge multiple workbook sheets (comma-separated) into one - // with same schema. E.g.: Item1.xlsx,Item2.xlsx,ItemAward*.xlsx. - repeated string merger = 14; - // Merge adjacent rows with the same key. If the key cell is not set, - // it will be treated the same as the nearest key above the same column. - bool adjacent_key = 15; - // In order to track field presence of basic types (numeric, string, bytes, - // and enums), the generated field will be labeled "optional". - // - // See https://protobuf.dev/programming-guides/field_presence/ - bool field_presence = 16; - // Indicate this XML sheet is a template or not. Template sheet structure will - // only be parsed based on metasheet "@TABLEAU" in comments. - bool template = 17; - // Sheet mode. - Mode mode = 18; - // Scatter convert multiple workbook sheets (comma-separated) separately - // with same schema. E.g.: Item1.xlsx,Item2.xlsx,ItemAward*.xlsx. - repeated string scatter = 19; - // Whether all fields in this sheet are optional (field name existence). - // If set to true, then: - // - table formats (Excel/CSV): field's column can be absent. - // - document formats (XML/YAML): field's name can be absent. - bool optional = 20; - // Sheet patch type. - Patch patch = 21; - // confgen: export JSON/Bin/Text files with parent dir created. - bool with_parent_dir = 22; - // confgen(scatter): export JSON/Bin/Text filenames without book name prefix. - bool scatter_without_book_name = 23; - // Protovalidate message-level rules. The value is a text-format - // representation of buf.validate.MessageRules, e.g.: "cel_expression:\"this.item_map.size() > 0\"". - // - // See https://github.com/bufbuild/protovalidate. - string validate = 24; - - ////////// Loader related options below ////////// - // Generate OrderedMap accessers or not. - bool ordered_map = 50; - // Generate index accessers, and multiple index columns are comma-separated. - // - // Single-column index - // - // Form: Column[@IndexName] - // - // If IndexName is not set, it will be this column’s parent struct type name. - // The columns in the angle brackets `<>` specify the sorting columns, which - // the result array of same index key sort by. - // - // Multi-column index - // - // Form: (Column1,Column2,...)[@IndexName] - // - // Examples: - // - ID - // - ID@Item - // - (ID,Type) - // - (ID,Type)@Item - // - (ID,Type)@Item - // - (ID,Type)@Item - // - ID, (ID,Type)@Item - repeated string index = 51; - - // Specify loader language options. - // Valid keys are: OrderedMap, Index, OrderedIndex. - // Different kvs must be seperated by ',' and one key value must be seperated - // by ':'. If one key doesn't exist in map, it means that this loader option - // is supported in all languages. Valid values are all combinations of "cpp", - // "go", "csharp" and "ts" with ' ' as seperator. - // - // Examples: - // - OrderedMap:cpp,Index:cpp go ts // ordered map supported in cpp, index - // supported in cpp, go and ts - // - OrderedMap:cpp // ordered map supported in cpp, index supported in all - // languages - map lang_options = 52; - - // Generate OrderedIndex accessers, and multiple index columns are comma-separated. - // Formats are same with index. - repeated string ordered_index = 53; -} - -message FieldOptions { - string name = 1; // Scalar type's variable name or composite type's variable name (prefix). - string note = 2; // Field note. Maybe in another language (Chinese). - string key = 3; // Only set when this field type is map or keyed-list. - Layout layout = 4; // For map/list types with cardinality. Default: LAYOUT_DEFAULT. - Span span = 5; // For list element or map value types. Default: SPAN_CROSS_CELL. - - FieldProp prop = 15; // Property of field. -} - -message FieldProp { - // Usage: {range:"1,10" refer:"Item.ID"} - - // Different interpretations of range: - // - number: value range - // - string: count of utf-8 code point - // - // Format: "1,10", "1,~", "~,10". - string range = 1; - // Whether the map key is unique in column. - // If not set, then auto deduce whether the map key is unique or not. - optional bool unique = 2; - // Ensure this field's value is in another sheet's - // column value space (aka message's field value space). - // - // Format: "SheetName.ColumnName" or "SheetName(SheetAlias).ColumnName" - // - // Example: - // - "SheetName.ColumnName": e.g. "Item.ID", without sheet alias, and - // the sheet name is the generated protobuf message name. - // - "SheetName(SheetAlias).ColumnName": e.g. "Item(ItemConf).ID", with - // sheet alias, and sheet alias is the generated protobuf message name. - string refer = 3; - // Ensure this field's value is a sequence and begins with this value. - // Mainly used for map key and list element. - optional int64 sequence = 4; - // Specify custom default value of scalar field. - string default = 5; - // Auto detect fixed size of horizontal list or map. - // - list size is detected by size of the max present list elements in name row. - // - map size is detected by size of the max present map items in name row. - bool fixed = 6; - // Specify fixed size of horizontal list or map. - uint32 size = 7; - // Specify cell data form for parsing. - Form form = 8; - // JSON name of this field. The value is set by protocol compiler. If the - // user has set a "json_name" option on this field, that option's value - // will be used. Otherwise, it's deduced from the field's name by converting - // it to camelCase. - string json_name = 9; - // Whether this field value is present (field value existence). - // If set to true, then do the following checks for different field types: - // - scalar/enum: cell data cannot be empty string (TODO: If this field's - // type is string, then how to set empty string explicitly?) - // - struct: check at least one field is present recursively - // - map/list: len(elements) > 0 - bool present = 10; - // Whether this field is optional (field name existence). - // If set to true, then: - // - table formats (Excel/CSV): field's column can be absent. - // - document formats (XML/YAML): field's name can be absent. - bool optional = 11; - // Field patch type. - Patch patch = 12; - // Field-level separator for separating: - // - incell list elements (scalar or struct). - // - incell map items. - // - // If set, it will overwrite sheet-level seq in WorksheetOptions. - string sep = 13; - // Field-level subseparator for separating: - // - key-value pair of each incell map item. - // - struct fields of each incell struct list element. - // - // If set, it will overwrite sheet-level subseq in WorksheetOptions. - string subsep = 14; - // NOTE: field number 15 (cross) is reserved for backward compatibility. - reserved 15; - // Specify the pattern of scalar, list element, and map value. - // - // For version (tableau.Version) field: - // - // Specify the dotted-decimal pattern of current cell. Each decimal - // number ranges from 0 to the corresponding part (MAX) of pattern. - // Default pattern: "255.255.255". - // - // TODO: use cases for more field types. - string pattern = 16; - // Ensure this field's value is in order. - Order order = 17; - // Protovalidate field-level rules of scalar and well-known types. The value is - // a text-format representation of buf.validate.FieldRules, e.g.: "string:{max_len:10}". - // - // See https://github.com/bufbuild/protovalidate. - string validate = 18; - // Protovalidate field-level rules of complex types: list, map. The value is a text-format - // representation of buf.validate.FieldRules, e.g.: "repeated:{min_items:1}". - // - // See https://github.com/bufbuild/protovalidate. - string validate_complex = 19; - // Protovalidate message-level rules for the nested message corresponding to - // this field. The value is a text-format representation of buf.validate.MessageRules, - // e.g.: cel_expression:"this.begin > this.end ? 'begin(%s) must <= end(%s)'.format([this.begin, this.end]): ''". - // - // See https://github.com/bufbuild/protovalidate. - string validate_message = 20; - // If true, this incell map/list field aggregates elements from repeated - // visits to the same enclosing message into a single combined collection. - // Repeated visits occur when multiple rows or columns parse into the same - // message, e.g.: - // - vertical map/keyed-list with same key across rows - // - horizontal map with same key across columns - // - vertical/horizontal list spanning multiple rows/columns (sibling - // incell fields revisited per row or column) - // - // Without aggregate (default): all visits must produce the identical incell - // value, otherwise error E2023 is reported. - // - // With aggregate: - // - incell map: merges entries from each visit; duplicate map keys across - // visits report error E2005. - // - incell list: appends elements from each visit unconditionally. - // - incell keyed-list: appends elements from each visit; duplicate keys - // across visits report error E2028. - bool aggregate = 21; -} - -// Layout of list and map. -enum Layout { - // Default: - // - vertical for struct map - // - incell for scalar map - // - horizontal for struct list - // - incell for scalar list - LAYOUT_DEFAULT = 0; - LAYOUT_VERTICAL = 1; // Vertical - LAYOUT_HORIZONTAL = 2; // Horizontal - LAYOUT_INCELL = 3; // Incell -} - -// Field data span of scalar and struct. -enum Span { - // Default: - // - inner cell for scalar type: bool, string, bytes, number, and enum. - // - cross cell for struct type: map-value, list-element, and struct-field. - SPAN_DEFAULT = 0; - SPAN_CROSS_CELL = 1; // The field data spans across multiple cells. - SPAN_INNER_CELL = 2; // The field data spans inside one cell. -} - -// Sheet mode. -enum Mode { - MODE_DEFAULT = 0; // Default mode. - MODE_ENUM_TYPE = 1; // Enum type: single definition in a sheet. - MODE_ENUM_TYPE_MULTI = 2; // Enum type: multiple definitions in a sheet. - MODE_STRUCT_TYPE = 3; // Struct type: single definition in a sheet. - MODE_STRUCT_TYPE_MULTI = 4; // Struct type: multiple definitions in a sheet. - MODE_UNION_TYPE = 5; // Union type: single definition in a sheet. - MODE_UNION_TYPE_MULTI = 6; // Union type: multiple definitions in a sheet. - - // UE DataTable references: - // - https://dev.epicgames.com/documentation/en-us/unreal-engine/data-driven-gameplay-elements-in-unreal-engine - // - https://dev.epicgames.com/documentation/en-us/unreal-engine/BlueprintAPI/EditorScripting/DataTable - MODE_UE_CSV = 10; // TODO: CSV format of UE DataTable. - MODE_UE_JSON = 11; // TODO: JSON format of UE DataTable. -} - -// Cell data form. -enum Form { - FORM_DEFAULT = 0; // Default form which confgen parser will parse. - FORM_TEXT = 1; // Refer: https://developers.google.com/protocol-buffers/docs/text-format-spec - FORM_JSON = 2; // Refer: https://developers.google.com/protocol-buffers/docs/proto3#json -} - -// Patch type for both sheet-level and field-level. -enum Patch { - PATCH_NONE = 0; - // 1 Sheet-level patch option "PATCH_REPLACE" - // - replace whole message - // 2 Top-field patch option "PATCH_REPLACE" - // - list: Clear field firstly, and then all elements of this list field - // in src are appended to the corresponded list fields in dst. - // - map: Clear field firstly, and then all entries of this map field in src - // are copied into the corresponding map field in dst. - PATCH_REPLACE = 1; - // Merge src into dst, which must be a message with the same descriptor. - // - scalar: Populated scalar fields in src are copied to dst. - // - message: Populated singular messages in src are merged into dst by - // recursively calling [proto.Merge](https://pkg.go.dev/google.golang.org/protobuf/proto#Merge). - // - list: The elements of every list field in src are appended to the - // corresponded list fields in dst. - // - map: The entries of every map field in src are copied into the - // corresponding map field in dst, possibly replacing existing entries. - // - unknown: The unknown fields of src are appended to the unknown - // fields of dst. - PATCH_MERGE = 2; -} - -// Field value order. -enum Order { - ORDER_NONE = 0; - ORDER_ASC = 1; // ascending: >= - ORDER_DESC = 2; // descending: <= - ORDER_STRICTLY_ASC = 3; // strictly ascending: > - ORDER_STRICTLY_DESC = 4; // strictly descending: < -} diff --git a/internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto b/internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto deleted file mode 100644 index 7c432c97..00000000 --- a/internal/x/xproto/protoc/embedded/tableau/protobuf/wellknown.proto +++ /dev/null @@ -1,115 +0,0 @@ -// Protoconf - Tableau's data interchange format -// https://tableauio.github.io/ - -syntax = "proto3"; - -package tableau; - -import "tableau/protobuf/tableau.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Tableau.Protobuf.Tableau"; -option go_package = "github.com/tableauio/tableau/proto/tableaupb"; -option java_multiple_files = true; -option java_outer_classname = "TableauProto"; -option java_package = "com.tableau.protobuf"; -option objc_class_prefix = "TPB"; - -// Supported formats: -// - N%: percentage, e.g.: 10% -// - N‰: per thounsand, e.g.: 10‰ -// - N‱: per ten thounsand, e.g.: 10‱ -// - N/D: simple fraction, e.g.: 3/4 -// - N: only numerator, e.g.: 3 is same to 3/1 -message Fraction { - int32 num = 1; // numerator - int32 den = 2; // denominator -} - -// Format: -// e.g.: ==10, !=1/2, <10%, <=10‰, >10%, >=10‱ -message Comparator { - Sign sign = 1; - Fraction value = 2; - - enum Sign { - SIGN_EQUAL = 0; // == - SIGN_NOT_EQUAL = 1; // != - SIGN_LESS = 2; // < - SIGN_LESS_OR_EQUAL = 3; // <= - SIGN_GREATER = 4; // > - SIGN_GREATER_OR_EQUAL = 5; // >= - } -} - -// TODO: -// - Vector2d for double 2D vector -// - Vector2l for int64 (long) 2D vector -// ... - -// A 2D vector using float coordinates. -// See https://docs.godotengine.org/en/stable/classes/class_vector2.html -message Vector2 { - float x = 1 [(tableau.field) = {name: "X"}]; - float y = 2 [(tableau.field) = {name: "Y"}]; -} - -// A 3D vector using float coordinates. -// See https://docs.godotengine.org/en/stable/classes/class_vector3.html -message Vector3 { - float x = 1 [(tableau.field) = {name: "X"}]; - float y = 2 [(tableau.field) = {name: "Y"}]; - float z = 3 [(tableau.field) = {name: "Z"}]; -} - -// A 4D vector using float coordinates. -// See https://docs.godotengine.org/en/stable/classes/class_vector4.html -message Vector4 { - float x = 1 [(tableau.field) = {name: "X"}]; - float y = 2 [(tableau.field) = {name: "Y"}]; - float z = 3 [(tableau.field) = {name: "Z"}]; - float w = 4 [(tableau.field) = {name: "W"}]; -} - -// A 2D vector using int32 coordinates. -// See https://docs.godotengine.org/en/stable/classes/class_vector2i.html -message Vector2i { - int32 x = 1 [(tableau.field) = {name: "X"}]; - int32 y = 2 [(tableau.field) = {name: "Y"}]; -} - -// A 3D vector using int32 coordinates. -// See https://docs.godotengine.org/en/stable/classes/class_vector3i.html -message Vector3i { - int32 x = 1 [(tableau.field) = {name: "X"}]; - int32 y = 2 [(tableau.field) = {name: "Y"}]; - int32 z = 3 [(tableau.field) = {name: "Z"}]; -} - -// A 4D vector using int32 coordinates. -// See https://docs.godotengine.org/en/stable/classes/class_vector4i.html -message Vector4i { - int32 x = 1 [(tableau.field) = {name: "X"}]; - int32 y = 2 [(tableau.field) = {name: "Y"}]; - int32 z = 3 [(tableau.field) = {name: "Z"}]; - int32 w = 4 [(tableau.field) = {name: "W"}]; -} - -// Version number in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation). -// The version form is "..[.]...". -// -// You can specify the version pattern as "..[.]...". -// - Each part with suffix "MAX" represents the max decimal value of each part in the dot-decimal notation. -// - Each part "XXX_MAX+1" represents the part's value occupying in an integer. -// - For example, the formula for general pattern ".." is: -// MAJOR*(MINOR_MAX+1)*(PATCH_MAX+1) + MINOR*(PATCH_MAX+1) + PATCH -// -// Default pattern: "255.255.255". -message Version { - string str = 1; // Version in string form. - uint64 val = 2; // Version in integer form. - uint32 major = 3; // Major version number. - uint32 minor = 4; // Minor version number. - uint32 patch = 5; // Patch version number. - repeated uint32 others = 6; // Other version numbers, such as build number, resource version, and so on. -} diff --git a/internal/x/xproto/protoc/gen_embedded.sh b/internal/x/xproto/protoc/gen_embedded.sh index c2da7ad3..0966110b 100755 --- a/internal/x/xproto/protoc/gen_embedded.sh +++ b/internal/x/xproto/protoc/gen_embedded.sh @@ -1,19 +1,10 @@ #!/usr/bin/env bash # Refreshes the embedded/ directory consumed by embed.go. # -# Invoked by `go generate ./...` (see embed.go). Run from the directory -# containing this script (the dir of embed.go); `go generate` guarantees -# that cwd. +# Invoked by `go generate ./...` (see embed.go). # -# Steps: -# 1. Wipe embedded/ to start clean. -# 2. Copy this repository's own proto/tableau/protobuf/*.proto files -# (top-level only — internal/ and unittest/ are intentionally skipped -# to match buf.yaml excludes). -# 3. Read the protovalidate commit pinned in buf.lock and `buf export` -# that exact commit so the vendored copy stays aligned with buf.lock. -# `buf export ` without a commit suffix pulls latest; -# buf.lock only governs intra-workspace resolution, not ad-hoc export. +# `buf export` ignores buf.lock, so we read the pinned protovalidate commit +# from buf.lock ourselves and pass it explicitly to stay in sync. set -euo pipefail @@ -21,9 +12,6 @@ REPO_ROOT="$(git rev-parse --show-toplevel)" BUF_LOCK="$REPO_ROOT/buf.lock" rm -rf embedded -mkdir -p embedded/tableau/protobuf - -cp "$REPO_ROOT"/proto/tableau/protobuf/*.proto embedded/tableau/protobuf/ commit=$(awk ' /name: buf.build\/bufbuild\/protovalidate/ { found = 1 } diff --git a/proto/tableau/protobuf/embed.go b/proto/tableau/protobuf/embed.go new file mode 100644 index 00000000..4085cab7 --- /dev/null +++ b/proto/tableau/protobuf/embed.go @@ -0,0 +1,15 @@ +// Package protobuf embeds this repository's own core .proto sources +// (tableau.proto and wellknown.proto) so that other Go packages — notably +// internal/x/xproto/protoc, which needs their source text to satisfy +// protocompile's experimental [source.Opener] — can reuse them directly +// instead of vendoring a second copy. +package protobuf + +import "embed" + +// FS embeds tableau.proto and wellknown.proto (top-level only; the +// internal/ and unittest/ subdirectories are intentionally excluded to +// match buf.yaml's unnamed-module includes). +// +//go:embed tableau.proto wellknown.proto +var FS embed.FS