diff --git a/Cargo.lock b/Cargo.lock index 3408e77..a05f727 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,18 @@ version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bitflags" version = "2.10.0" @@ -35,12 +47,65 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.109", +] + +[[package]] +name = "deranged" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +dependencies = [ + "powerfmt", +] + [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +[[package]] +name = "email_address" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449" +dependencies = [ + "serde", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -69,6 +134,12 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "getrandom" version = "0.3.4" @@ -93,6 +164,22 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "indexmap" version = "2.12.0" @@ -103,6 +190,15 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.14.0" @@ -112,6 +208,12 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + [[package]] name = "libc" version = "0.2.177" @@ -142,12 +244,36 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + [[package]] name = "pbjson-build" version = "0.8.0" @@ -155,7 +281,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af22d08a625a2213a78dbb0ffa253318c5c79ce3133d32d296655a7bdfb02095" dependencies = [ "heck", - "itertools", + "itertools 0.14.0", "prost", "prost-types", ] @@ -170,6 +296,12 @@ dependencies = [ "indexmap", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "prettyplease" version = "0.2.37" @@ -177,7 +309,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn", + "syn 2.0.109", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", ] [[package]] @@ -206,14 +362,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac6c3320f9abac597dcbc668774ef006702672474aad53c6d596b62e487b40b1" dependencies = [ "heck", - "itertools", + "itertools 0.14.0", "log", "multimap", "once_cell", "petgraph", + "prettyplease", "prost", "prost-types", "regex", + "syn 2.0.109", "tempfile", ] @@ -224,10 +382,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425" dependencies = [ "anyhow", - "itertools", + "itertools 0.14.0", "proc-macro2", "quote", - "syn", + "syn 2.0.109", +] + +[[package]] +name = "prost-reflect" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89a3ac73ec9a9118131a4594c9d336631a07852220a1d0ae03ee36b04503a063" +dependencies = [ + "base64", + "prost", + "prost-reflect-derive", + "prost-types", + "serde", + "serde-value", +] + +[[package]] +name = "prost-reflect-build" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8214ae2c30bbac390db0134d08300e770ef89b6d4e5abf855e8d300eded87e28" +dependencies = [ + "prost-build", + "prost-reflect", +] + +[[package]] +name = "prost-reflect-derive" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b6d90e29fa6c0d13c2c19ba5e4b3fb0efbf5975d27bcf4e260b7b15455bcabe" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.109", ] [[package]] @@ -239,6 +432,74 @@ dependencies = [ "prost", ] +[[package]] +name = "prost-validate" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245440b64a9bd908b07b38e0be4d126409192b8c8720d9ed73d157a6c920287f" +dependencies = [ + "anyhow", + "email_address", + "http", + "itertools 0.13.0", + "once_cell", + "prost", + "prost-types", + "regex", + "thiserror", + "time", +] + +[[package]] +name = "prost-validate-build" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "631123f233090223702320ae932346d3ff7ca919c5b9dc2dcdd92199c088f93d" +dependencies = [ + "heck", + "prost-build", + "prost-reflect", + "prost-validate-derive-core", + "prost-validate-types", +] + +[[package]] +name = "prost-validate-derive-core" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ba8034c013ab5d33ccf2633b11488023987888f7765a257b81635ffd915b00" +dependencies = [ + "anyhow", + "darling", + "heck", + "once_cell", + "proc-macro-error", + "proc-macro2", + "prost-reflect", + "prost-types", + "prost-validate-types", + "quote", + "regex", + "syn 2.0.109", + "time", +] + +[[package]] +name = "prost-validate-types" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d03f58b66e7364b41d9c852cfed68668f235ecc21f5d107933dea2edf20d227" +dependencies = [ + "anyhow", + "once_cell", + "prost", + "prost-build", + "prost-reflect", + "prost-reflect-build", + "prost-types", + "time", +] + [[package]] name = "protoc-gen-prost" version = "0.4.0" @@ -277,6 +538,24 @@ dependencies = [ [[package]] name = "protoc-gen-prost-validate" version = "0.0.1" +dependencies = [ + "once_cell", + "prettyplease", + "proc-macro2", + "prost", + "prost-build", + "prost-reflect", + "prost-types", + "prost-validate", + "prost-validate-build", + "prost-validate-derive-core", + "prost-validate-types", + "protoc-gen-prost", + "quote", + "regex", + "syn 2.0.109", + "time", +] [[package]] name = "protoc-gen-tonic" @@ -291,7 +570,7 @@ dependencies = [ "protoc-gen-prost", "quote", "regex", - "syn", + "syn 2.0.109", "tonic-build", ] @@ -356,6 +635,61 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.109", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.109" @@ -380,6 +714,45 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.109", +] + +[[package]] +name = "time" +version = "0.3.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b" + [[package]] name = "tonic-build" version = "0.14.2" @@ -389,7 +762,7 @@ dependencies = [ "prettyplease", "proc-macro2", "quote", - "syn", + "syn 2.0.109", ] [[package]] @@ -398,6 +771,12 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + [[package]] name = "wasip2" version = "1.0.1+wasi-0.2.4" diff --git a/example/build-with-buf/Cargo.toml b/example/build-with-buf/Cargo.toml index b020f30..c8ea6dc 100644 --- a/example/build-with-buf/Cargo.toml +++ b/example/build-with-buf/Cargo.toml @@ -20,5 +20,6 @@ pbjson-types = "0.8.0" serde = "1.0.228" tonic = { version = "0.14.2", features = ["gzip"] } tonic-prost = "0.14.2" +prost-validate = { version = "0.2.9" } [workspace] diff --git a/example/build-with-buf/buf.gen.yaml b/example/build-with-buf/buf.gen.yaml index bfc07fd..182cb96 100644 --- a/example/build-with-buf/buf.gen.yaml +++ b/example/build-with-buf/buf.gen.yaml @@ -4,13 +4,13 @@ plugins: #path: ../../target/debug/protoc-gen-prost out: src/gen opt: -# - bytes=. - - compile_well_known_types - - extern_path=.google.protobuf=::pbjson_types + # - bytes=. + # - compile_well_known_types + # - extern_path=.google.protobuf=::pbjson_types - file_descriptor_set - enable_type_names - local: protoc-gen-prost-serde - #path: ../../target/debug/protoc-gen-prost-serde + # path: ../../target/debug/protoc-gen-prost-serde out: src/gen - local: protoc-gen-tonic #path: ../../target/debug/protoc-gen-tonic @@ -25,5 +25,15 @@ plugins: opt: - include_file=src/gen/mod.rs - gen_crate + - local: protoc-gen-prost-validate + # path: ../../target/debug/protoc-gen-prost-validate + out: src/gen + strategy: all + opt: + # - bytes=. + # - compile_well_known_types + # - extern_path=.google.protobuf=::pbjson_types + - enable_type_names + inputs: - directory: proto diff --git a/example/build-with-buf/proto/buf.lock b/example/build-with-buf/proto/buf.lock new file mode 100644 index 0000000..fafef03 --- /dev/null +++ b/example/build-with-buf/proto/buf.lock @@ -0,0 +1,8 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: envoyproxy + repository: protoc-gen-validate + commit: daf171c6cdb54629b5f51e345a79e4dd + digest: shake256:4ae167d7eed10da5f83a3f5df8c670d249170f11b1f2fd19afda06be2cff4d47dcc95e9e4a15151ecc8ce2d3d3614caf9a04d3ad82fb768a3870dedfa9455f36 diff --git a/example/build-with-buf/proto/buf.yaml b/example/build-with-buf/proto/buf.yaml new file mode 100644 index 0000000..cb998d1 --- /dev/null +++ b/example/build-with-buf/proto/buf.yaml @@ -0,0 +1,3 @@ +version: v1 +deps: +- buf.build/envoyproxy/protoc-gen-validate diff --git a/example/build-with-buf/proto/example/ExampleRequest.proto b/example/build-with-buf/proto/example/ExampleRequest.proto index d10b2f5..1f43cb5 100644 --- a/example/build-with-buf/proto/example/ExampleRequest.proto +++ b/example/build-with-buf/proto/example/ExampleRequest.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package example; +import "validate/validate.proto"; + message ExampleRequest { - string example = 1; + string example = 1 [(validate.rules).string = {min_len: 1, max_len: 10}]; } diff --git a/protoc-gen-prost-validate/Cargo.toml b/protoc-gen-prost-validate/Cargo.toml index 2c2700e..5c0abd8 100644 --- a/protoc-gen-prost-validate/Cargo.toml +++ b/protoc-gen-prost-validate/Cargo.toml @@ -1,11 +1,34 @@ [package] name = "protoc-gen-prost-validate" version = "0.0.1" -authors = ["Marcus Griep "] +authors = ["Marcus Griep ", "Adphi "] description = "Coming soon…" license = "Apache-2.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[test]] +name = "harness" +path = "tests/harness.rs" [dependencies] +prost-build.workspace = true +prost-types.workspace = true +prost.workspace = true +protoc-gen-prost = { version = "0.4.0", path = "../protoc-gen-prost" } +prost-validate-build = { version = "0.2.9" } +prost-validate-derive-core = { version = "0.2.9" } +prost-validate-types = { version = "0.2.9" } +syn = "2.0.75" +proc-macro2 = "1.0.86" +prost-reflect = "0.16.2" +quote = "1" +prettyplease = "0.2.9" + +[dev-dependencies] +prost = "0.14.1" +prost-types = "0.14.1" +prost-validate = { version = "0.2.9" } +time = "0.3.36" +regex = "1" +once_cell = "1.20.2" diff --git a/protoc-gen-prost-validate/buf.gen.yaml b/protoc-gen-prost-validate/buf.gen.yaml new file mode 100644 index 0000000..f83d375 --- /dev/null +++ b/protoc-gen-prost-validate/buf.gen.yaml @@ -0,0 +1,14 @@ +version: v2 +plugins: + - local: ../target/debug/protoc-gen-prost + out: tests/cases/gen + strategy: all + - local: ../target/debug/protoc-gen-prost-validate + out: tests/cases/gen + strategy: all + - local: ../target/debug/protoc-gen-prost-crate + out: . + strategy: all + opt: + - include_file=tests/cases/gen/mod.rs + - no_features diff --git a/protoc-gen-prost-validate/buf.work.yaml b/protoc-gen-prost-validate/buf.work.yaml new file mode 100644 index 0000000..1b69d27 --- /dev/null +++ b/protoc-gen-prost-validate/buf.work.yaml @@ -0,0 +1,3 @@ +version: v1 +directories: + - tests/proto diff --git a/protoc-gen-prost-validate/src/generator.rs b/protoc-gen-prost-validate/src/generator.rs new file mode 100644 index 0000000..6fff0b7 --- /dev/null +++ b/protoc-gen-prost-validate/src/generator.rs @@ -0,0 +1,199 @@ +use proc_macro2::TokenStream; +use prost::Message; +use prost_build::Module; +use prost_reflect::DescriptorPool; +use prost_types::compiler::code_generator_response::File; +use prost_validate_build::Builder; +use protoc_gen_prost::{Error, Generator, ModuleRequest, ModuleRequestSet, Result}; +use std::collections::HashMap; +use syn::__private::quote::quote; +use syn::__private::ToTokens; + +pub struct ProstValidateGenerator { + builder: Builder, + config: prost_build::Config, + insert_include: bool, +} + +impl Generator for ProstValidateGenerator { + fn generate(&mut self, module_request_set: &ModuleRequestSet) -> Result { + let file_contents = self.generate_prost(module_request_set)?; + Ok(module_request_set + .requests() + .filter_map(|(module, request)| { + self.generate_one(module, request, &file_contents) + .transpose() + }) + .collect::, Error>>()? + .iter() + .flatten() + .cloned() + .collect()) + } +} + +impl ProstValidateGenerator { + pub fn new(config: prost_build::Config, insert_include: bool) -> Self { + Self { + builder: Builder::new(), + config, + insert_include, + } + } + + fn generate_prost( + &mut self, + module_request_set: &ModuleRequestSet, + ) -> std::result::Result, Error> { + // we need to generate a raw file descriptor set in order to build prost-reflect the descriptor pool + // otherwise we can't annotate the config due to missing options in the prost crates. + let file_descriptor_set_bytes = RawProtosSet { + file: module_request_set + .requests() + .map(|(_, request)| request.raw_files()) + .flatten() + .map(|f| f.to_vec()) + .collect::>(), + } + .encode_to_vec(); + let pool = DescriptorPool::decode(file_descriptor_set_bytes.as_slice())?; + + self.builder.annotate(&mut self.config, &pool); + let prost_requests: Vec<_> = module_request_set + .requests() + .flat_map(|(module, request)| { + request.files().map(|proto| (module.clone(), proto.clone())) + }) + .collect(); + + Ok(self.config.generate(prost_requests)?) + } + + fn generate_one( + &mut self, + module: &Module, + request: &ModuleRequest, + file_contents: &HashMap, + ) -> std::result::Result>, Error> { + let content = match file_contents.get(module) { + Some(content) => content, + None => return Ok(None), + }; + let output_filename = format!("{}.validate.rs", request.proto_package_name()); + + let mut file_stream = TokenStream::new(); + syn::parse_file(content) + .expect("failed to parse generated file") + .items + .iter() + .filter_map(filter_item) + .flatten() + .map(|item| prost_validate_derive_core::derive_with_module(item.stream, item.module)) + .for_each(|stream| stream.to_tokens(&mut file_stream)); + + if file_stream.is_empty() { + return Ok(None); + } + + let mut res = Vec::with_capacity(2); + if self.insert_include { + res.push( + match request.append_to_file(|buf| { + buf.push_str("include!(\""); + buf.push_str(&output_filename); + buf.push_str("\");\n"); + }) { + Some(file) => file, + None => return Ok(None), + }, + ); + } + + let file = syn::parse_file(file_stream.to_string().as_str())?; + let content = format!( + "// @generated by protoc-gen-prost-validate\n{}", + prettyplease::unparse(&file).as_str() + ); + let out_dir = request.output_dir(); + res.push(File { + name: Some(out_dir + &output_filename), + content: Some(content), + ..File::default() + }); + Ok(Some(res)) + } +} + +struct Item { + module: Option, + stream: TokenStream, +} + +fn filter_item(item: &syn::Item) -> Option> { + do_filter_item(item, None) +} + +fn do_filter_item(item: &syn::Item, module: Option) -> Option> { + match item { + syn::Item::Struct(s) => { + if has_validator_derive(&s.attrs) { + Some(vec![Item { + stream: item.to_token_stream(), + module, + }]) + } else { + None + } + } + syn::Item::Enum(e) => { + if has_validator_derive(&e.attrs) { + Some(vec![Item { + stream: item.to_token_stream(), + module, + }]) + } else { + None + } + } + syn::Item::Mod(m) => { + let module = match module { + Some(m2) => { + let ident = m.ident.to_token_stream(); + Some(quote! { #m2::#ident }) + } + None => Some(m.ident.to_token_stream()), + }; + let mut items = Vec::new(); + for item in m.content.as_ref()?.1.iter() { + if let Some(item) = do_filter_item(item, module.clone()) { + items.extend(item); + } + } + Some(items) + } + _ => None, + } +} + +fn has_validator_derive(attrs: &Vec) -> bool { + let mut has_validator = false; + for attr in attrs { + if attr.path().is_ident("derive") { + let _ = attr.parse_nested_meta(|meta| { + has_validator = + meta.path.to_token_stream().to_string() == ":: prost_validate :: Validator"; + Ok(()) + }); + } + if has_validator { + return true; + } + } + false +} + +#[derive(Clone, PartialEq, ::prost::Message)] +struct RawProtosSet { + #[prost(bytes = "vec", repeated, tag = "1")] + pub file: Vec>, +} diff --git a/protoc-gen-prost-validate/src/lib.rs b/protoc-gen-prost-validate/src/lib.rs new file mode 100644 index 0000000..4c0fe92 --- /dev/null +++ b/protoc-gen-prost-validate/src/lib.rs @@ -0,0 +1,64 @@ +mod generator; + +use crate::generator::ProstValidateGenerator; +use prost::Message; +use prost_types::compiler::CodeGeneratorRequest; +use protoc_gen_prost::{ + Generator, InvalidParameter, ModuleRequestSet, Param, Params, ProstParameters, +}; +use std::str::FromStr; + +/// Parameters use to configure [`Generator`]s built into `protoc-gen-prost-validate` +/// +/// [`Generator`]: crate::Generator +#[derive(Debug, Default)] +pub struct Parameters { + /// Prost parameters, used to generate [`prost_build::Config`] + pub prost: ProstParameters, + + /// Whether to include the `include!` directive in the prost generated file + pub no_include: bool, +} + +impl FromStr for Parameters { + type Err = InvalidParameter; + fn from_str(s: &str) -> std::result::Result { + let mut ret_val = Self::default(); + for param in Params::from_protoc_plugin_opts(s)? { + if let Err(param) = ret_val.prost.try_handle_parameter(param) { + match param { + Param::Parameter { + param: "no_include", + } + | Param::Value { + param: "no_include", + value: "true", + } => ret_val.no_include = true, + Param::Value { + param: "no_include", + value: "false", + } => (), + _ => return Err(InvalidParameter::from(param)), + } + } + } + + Ok(ret_val) + } +} + +/// Execute the core _Prost!_ generator from a raw [`CodeGeneratorRequest`] +pub fn execute(raw_request: &[u8]) -> protoc_gen_prost::Result { + let request = CodeGeneratorRequest::decode(raw_request)?; + let params = request.parameter().parse::()?; + let module_request_set = ModuleRequestSet::new( + request.file_to_generate, + request.proto_file, + raw_request, + params.prost.default_package_filename(), + params.prost.flat_output_dir, + )?; + let files = ProstValidateGenerator::new(params.prost.to_prost_config(), !params.no_include) + .generate(&module_request_set)?; + Ok(files) +} diff --git a/protoc-gen-prost-validate/src/main.rs b/protoc-gen-prost-validate/src/main.rs index e7a11a9..dd248ec 100644 --- a/protoc-gen-prost-validate/src/main.rs +++ b/protoc-gen-prost-validate/src/main.rs @@ -1,3 +1,26 @@ -fn main() { - println!("Hello, world!"); +use std::{ + env, + io::{self, Read, Write}, + process::exit, +}; + +use prost::Message; +use protoc_gen_prost::GeneratorResultExt; + +fn main() -> io::Result<()> { + if env::args().any(|x| x == "--version") { + println!(env!("CARGO_PKG_VERSION")); + exit(0); + } + + let mut buf = Vec::new(); + io::stdin().read_to_end(&mut buf)?; + + let response = protoc_gen_prost_validate::execute(buf.as_slice()).unwrap_codegen_response(); + + buf.clear(); + response.encode(&mut buf).expect("error encoding response"); + io::stdout().write_all(&buf)?; + + Ok(()) } diff --git a/protoc-gen-prost-validate/tests/cases/cases.rs b/protoc-gen-prost-validate/tests/cases/cases.rs new file mode 100644 index 0000000..4496956 --- /dev/null +++ b/protoc-gen-prost-validate/tests/cases/cases.rs @@ -0,0 +1,8590 @@ +use super::gen::tests::harness::cases; +use super::gen::tests::harness::cases::message_required_oneof::One; +use super::gen::tests::harness::cases::*; +use super::{now, Factory}; +use once_cell::sync::Lazy; +use prost_types::{Any, Duration, Timestamp}; +use prost_validate::Validator; +use std::collections::HashMap; + +pub static CASES: Lazy> = Lazy::new(|| { + HashMap::from([ + ( + "float_none_valid", + Box::new(|| { + ( + Box::new(FloatNone { val: -1.23456 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "float_const_valid", + Box::new(|| (Box::new(FloatConst { val: 1.23 }) as Box, 0)) as Factory, + ), + ( + "float_const_invalid", + Box::new(|| (Box::new(FloatConst { val: 4.56 }) as Box, 1)) as Factory, + ), + ( + "float_in_valid", + Box::new(|| (Box::new(FloatIn { val: 7.89 }) as Box, 0)) as Factory, + ), + ( + "float_in_invalid", + Box::new(|| (Box::new(FloatIn { val: 10.11 }) as Box, 1)) as Factory, + ), + ( + "float_not_in_valid", + Box::new(|| (Box::new(FloatNotIn { val: 1. }) as Box, 0)) as Factory, + ), + ( + "float_not_in_invalid", + Box::new(|| (Box::new(FloatNotIn { val: 0. }) as Box, 1)) as Factory, + ), + ( + "float_lt_valid", + Box::new(|| (Box::new(FloatLt { val: -1. }) as Box, 0)) as Factory, + ), + ( + "float_lt_invalid_equal", + Box::new(|| (Box::new(FloatLt { val: 0. }) as Box, 1)) as Factory, + ), + ( + "float_lt_invalid", + Box::new(|| (Box::new(FloatLt { val: 1. }) as Box, 1)) as Factory, + ), + ( + "float_lte_valid", + Box::new(|| (Box::new(FloatLte { val: 63. }) as Box, 0)) as Factory, + ), + ( + "float_lte_valid_equal", + Box::new(|| (Box::new(FloatLte { val: 64. }) as Box, 0)) as Factory, + ), + ( + "float_lte_invalid", + Box::new(|| (Box::new(FloatLte { val: 65. }) as Box, 1)) as Factory, + ), + ( + "float_gt_valid", + Box::new(|| (Box::new(FloatGt { val: 17. }) as Box, 0)) as Factory, + ), + ( + "float_gt_invalid_equal", + Box::new(|| (Box::new(FloatGt { val: 16. }) as Box, 1)) as Factory, + ), + ( + "float_gt_invalid", + Box::new(|| (Box::new(FloatGt { val: 15. }) as Box, 1)) as Factory, + ), + ( + "float_gte_valid", + Box::new(|| (Box::new(FloatGte { val: 9. }) as Box, 0)) as Factory, + ), + ( + "float_gte_valid_equal", + Box::new(|| (Box::new(FloatGte { val: 8. }) as Box, 0)) as Factory, + ), + ( + "float_gte_invalid", + Box::new(|| (Box::new(FloatGte { val: 7. }) as Box, 1)) as Factory, + ), + ( + "float_gt_lt_valid", + Box::new(|| (Box::new(FloatGtlt { val: 5. }) as Box, 0)) as Factory, + ), + ( + "float_gt_lt_invalid_above", + Box::new(|| (Box::new(FloatGtlt { val: 11. }) as Box, 1)) as Factory, + ), + ( + "float_gt_lt_invalid_below", + Box::new(|| (Box::new(FloatGtlt { val: -1. }) as Box, 1)) as Factory, + ), + ( + "float_gt_lt_invalid_max", + Box::new(|| (Box::new(FloatGtlt { val: 10. }) as Box, 1)) as Factory, + ), + ( + "float_gt_lt_invalid_min", + Box::new(|| (Box::new(FloatGtlt { val: 0. }) as Box, 1)) as Factory, + ), + ( + "float_exclusive_gt_lt_valid_above", + Box::new(|| (Box::new(FloatExLtgt { val: 11. }) as Box, 0)) as Factory, + ), + ( + "float_exclusive_gt_lt_valid_below", + Box::new(|| (Box::new(FloatExLtgt { val: -1. }) as Box, 0)) as Factory, + ), + ( + "float_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(FloatExLtgt { val: 5. }) as Box, 1)) as Factory, + ), + ( + "float_exclusive_gt_lt_invalid_max", + Box::new(|| (Box::new(FloatExLtgt { val: 10. }) as Box, 1)) as Factory, + ), + ( + "float_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(FloatExLtgt { val: 0. }) as Box, 1)) as Factory, + ), + ( + "float_gte_lte_valid", + Box::new(|| (Box::new(FloatGtelte { val: 200. }) as Box, 0)) as Factory, + ), + ( + "float_gte_lte_valid_max", + Box::new(|| (Box::new(FloatGtelte { val: 256. }) as Box, 0)) as Factory, + ), + ( + "float_gte_lte_valid_min", + Box::new(|| (Box::new(FloatGtelte { val: 128. }) as Box, 0)) as Factory, + ), + ( + "float_gte_lte_invalid_above", + Box::new(|| (Box::new(FloatGtelte { val: 300. }) as Box, 1)) as Factory, + ), + ( + "float_gte_lte_invalid_below", + Box::new(|| (Box::new(FloatGtelte { val: 100. }) as Box, 1)) as Factory, + ), + ( + "float_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(FloatExGtelte { val: 300. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "float_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(FloatExGtelte { val: 100. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "float_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(FloatExGtelte { val: 256. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "float_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(FloatExGtelte { val: 128. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "float_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(FloatExGtelte { val: 200. }) as Box, + 1, + ) + }) as Factory, + ), + ( + "float_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(FloatIgnore { val: 0. }) as Box, 0)) as Factory, + ), + ( + "double_none_valid", + Box::new(|| { + ( + Box::new(DoubleNone { val: -1.23456 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "double_const_valid", + Box::new(|| (Box::new(DoubleConst { val: 1.23 }) as Box, 0)) as Factory, + ), + ( + "double_const_invalid", + Box::new(|| (Box::new(DoubleConst { val: 4.56 }) as Box, 1)) as Factory, + ), + ( + "double_in_valid", + Box::new(|| (Box::new(DoubleIn { val: 7.89 }) as Box, 0)) as Factory, + ), + ( + "double_in_invalid", + Box::new(|| (Box::new(DoubleIn { val: 10.11 }) as Box, 1)) as Factory, + ), + ( + "double_not_in_valid", + Box::new(|| (Box::new(DoubleNotIn { val: 1. }) as Box, 0)) as Factory, + ), + ( + "double_not_in_invalid", + Box::new(|| (Box::new(DoubleNotIn { val: 0. }) as Box, 1)) as Factory, + ), + ( + "double_lt_valid", + Box::new(|| (Box::new(DoubleLt { val: -1. }) as Box, 0)) as Factory, + ), + ( + "double_lt_invalid_equal", + Box::new(|| (Box::new(DoubleLt { val: 0. }) as Box, 1)) as Factory, + ), + ( + "double_lt_invalid", + Box::new(|| (Box::new(DoubleLt { val: 1. }) as Box, 1)) as Factory, + ), + ( + "double_lte_valid", + Box::new(|| (Box::new(DoubleLte { val: 63. }) as Box, 0)) as Factory, + ), + ( + "double_lte_valid_equal", + Box::new(|| (Box::new(DoubleLte { val: 64. }) as Box, 0)) as Factory, + ), + ( + "double_lte_invalid", + Box::new(|| (Box::new(DoubleLte { val: 65. }) as Box, 1)) as Factory, + ), + ( + "double_gt_valid", + Box::new(|| (Box::new(DoubleGt { val: 17. }) as Box, 0)) as Factory, + ), + ( + "double_gt_invalid_equal", + Box::new(|| (Box::new(DoubleGt { val: 16. }) as Box, 1)) as Factory, + ), + ( + "double_gt_invalid", + Box::new(|| (Box::new(DoubleGt { val: 15. }) as Box, 1)) as Factory, + ), + ( + "double_gte_valid", + Box::new(|| (Box::new(DoubleGte { val: 9. }) as Box, 0)) as Factory, + ), + ( + "double_gte_valid_equal", + Box::new(|| (Box::new(DoubleGte { val: 8. }) as Box, 0)) as Factory, + ), + ( + "double_gte_invalid", + Box::new(|| (Box::new(DoubleGte { val: 7. }) as Box, 1)) as Factory, + ), + ( + "double_gt_lt_valid", + Box::new(|| (Box::new(DoubleGtlt { val: 5. }) as Box, 0)) as Factory, + ), + ( + "double_gt_lt_invalid_above", + Box::new(|| (Box::new(DoubleGtlt { val: 11. }) as Box, 1)) as Factory, + ), + ( + "double_gt_lt_invalid_below", + Box::new(|| (Box::new(DoubleGtlt { val: -1. }) as Box, 1)) as Factory, + ), + ( + "double_gt_lt_invalid_max", + Box::new(|| (Box::new(DoubleGtlt { val: 10. }) as Box, 1)) as Factory, + ), + ( + "double_gt_lt_invalid_min", + Box::new(|| (Box::new(DoubleGtlt { val: 0. }) as Box, 1)) as Factory, + ), + ( + "double_exclusive_gt_lt_valid_above", + Box::new(|| (Box::new(DoubleExLtgt { val: 11. }) as Box, 0)) as Factory, + ), + ( + "double_exclusive_gt_lt_valid_below", + Box::new(|| (Box::new(DoubleExLtgt { val: -1. }) as Box, 0)) as Factory, + ), + ( + "double_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(DoubleExLtgt { val: 5. }) as Box, 1)) as Factory, + ), + ( + "double_exclusive_gt_lt_invalid_max", + Box::new(|| (Box::new(DoubleExLtgt { val: 10. }) as Box, 1)) as Factory, + ), + ( + "double_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(DoubleExLtgt { val: 0. }) as Box, 1)) as Factory, + ), + ( + "double_gte_lte_valid", + Box::new(|| { + ( + Box::new(DoubleGtelte { val: 200. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "double_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(DoubleGtelte { val: 256. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "double_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(DoubleGtelte { val: 128. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "double_gte_lte_invalid_above", + Box::new(|| { + ( + Box::new(DoubleGtelte { val: 300. }) as Box, + 1, + ) + }) as Factory, + ), + ( + "double_gte_lte_invalid_below", + Box::new(|| { + ( + Box::new(DoubleGtelte { val: 100. }) as Box, + 1, + ) + }) as Factory, + ), + ( + "double_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(DoubleExGtelte { val: 300. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "double_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(DoubleExGtelte { val: 100. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "double_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(DoubleExGtelte { val: 256. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "double_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(DoubleExGtelte { val: 128. }) as Box, + 0, + ) + }) as Factory, + ), + ( + "double_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(DoubleExGtelte { val: 200. }) as Box, + 1, + ) + }) as Factory, + ), + ( + "double_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(DoubleIgnore { val: 0. }) as Box, 0)) as Factory, + ), + ( + "int32_none_valid", + Box::new(|| (Box::new(Int32None { val: 123 }) as Box, 0)) as Factory, + ), + ( + "int32_const_valid", + Box::new(|| (Box::new(Int32Const { val: 1 }) as Box, 0)) as Factory, + ), + ( + "int32_const_invalid", + Box::new(|| (Box::new(Int32Const { val: 2 }) as Box, 1)) as Factory, + ), + ( + "int32_in_valid", + Box::new(|| (Box::new(Int32In { val: 3 }) as Box, 0)) as Factory, + ), + ( + "int32_in_invalid", + Box::new(|| (Box::new(Int32In { val: 5 }) as Box, 1)) as Factory, + ), + ( + "int32_not_in_valid", + Box::new(|| (Box::new(Int32NotIn { val: 1 }) as Box, 0)) as Factory, + ), + ( + "int32_not_in_invalid", + Box::new(|| (Box::new(Int32NotIn { val: 0 }) as Box, 1)) as Factory, + ), + ( + "int32_lt_valid", + Box::new(|| (Box::new(Int32Lt { val: -1 }) as Box, 0)) as Factory, + ), + ( + "int32_lt_invalid_equal", + Box::new(|| (Box::new(Int32Lt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "int32_lt_invalid", + Box::new(|| (Box::new(Int32Lt { val: 1 }) as Box, 1)) as Factory, + ), + ( + "int32_lte_valid", + Box::new(|| (Box::new(Int32Lte { val: 63 }) as Box, 0)) as Factory, + ), + ( + "int32_lte_valid_equal", + Box::new(|| (Box::new(Int32Lte { val: 64 }) as Box, 0)) as Factory, + ), + ( + "int32_lte_invalid", + Box::new(|| (Box::new(Int32Lte { val: 65 }) as Box, 1)) as Factory, + ), + ( + "int32_gt_valid", + Box::new(|| (Box::new(Int32Gt { val: 17 }) as Box, 0)) as Factory, + ), + ( + "int32_gt_invalid_equal", + Box::new(|| (Box::new(Int32Gt { val: 16 }) as Box, 1)) as Factory, + ), + ( + "int32_gt_invalid", + Box::new(|| (Box::new(Int32Gt { val: 15 }) as Box, 1)) as Factory, + ), + ( + "int32_gte_valid", + Box::new(|| (Box::new(Int32Gte { val: 9 }) as Box, 0)) as Factory, + ), + ( + "int32_gte_valid_equal", + Box::new(|| (Box::new(Int32Gte { val: 8 }) as Box, 0)) as Factory, + ), + ( + "int32_gte_invalid", + Box::new(|| (Box::new(Int32Gte { val: 7 }) as Box, 1)) as Factory, + ), + ( + "int32_gt_lt_valid", + Box::new(|| (Box::new(Int32Gtlt { val: 5 }) as Box, 0)) as Factory, + ), + ( + "int32_gt_lt_invalid_above", + Box::new(|| (Box::new(Int32Gtlt { val: 11 }) as Box, 1)) as Factory, + ), + ( + "int32_gt_lt_invalid_below", + Box::new(|| (Box::new(Int32Gtlt { val: -1 }) as Box, 1)) as Factory, + ), + ( + "int32_gt_lt_invalid_max", + Box::new(|| (Box::new(Int32Gtlt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "int32_gt_lt_invalid_min", + Box::new(|| (Box::new(Int32Gtlt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "int32_exclusive_gt_lt_valid_above", + Box::new(|| (Box::new(Int32ExLtgt { val: 11 }) as Box, 0)) as Factory, + ), + ( + "int32_exclusive_gt_lt_valid_below", + Box::new(|| (Box::new(Int32ExLtgt { val: -1 }) as Box, 0)) as Factory, + ), + ( + "int32_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(Int32ExLtgt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "int32_exclusive_gt_lt_invalid_max", + Box::new(|| (Box::new(Int32ExLtgt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "int32_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(Int32ExLtgt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "int32_gte_lte_valid", + Box::new(|| (Box::new(Int32Gtelte { val: 200 }) as Box, 0)) as Factory, + ), + ( + "int32_gte_lte_valid_max", + Box::new(|| (Box::new(Int32Gtelte { val: 256 }) as Box, 0)) as Factory, + ), + ( + "int32_gte_lte_valid_min", + Box::new(|| (Box::new(Int32Gtelte { val: 128 }) as Box, 0)) as Factory, + ), + ( + "int32_gte_lte_invalid_above", + Box::new(|| (Box::new(Int32Gtelte { val: 300 }) as Box, 1)) as Factory, + ), + ( + "int32_gte_lte_invalid_below", + Box::new(|| (Box::new(Int32Gtelte { val: 100 }) as Box, 1)) as Factory, + ), + ( + "int32_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(Int32ExGtelte { val: 300 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "int32_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(Int32ExGtelte { val: 100 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "int32_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(Int32ExGtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "int32_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(Int32ExGtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "int32_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(Int32ExGtelte { val: 200 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "int32_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(Int32Ignore { val: 0 }) as Box, 0)) as Factory, + ), + ( + "int64_none_valid", + Box::new(|| (Box::new(Int64None { val: 123 }) as Box, 0)) as Factory, + ), + ( + "int64_const_valid", + Box::new(|| (Box::new(Int64Const { val: 1 }) as Box, 0)) as Factory, + ), + ( + "int64_const_invalid", + Box::new(|| (Box::new(Int64Const { val: 2 }) as Box, 1)) as Factory, + ), + ( + "int64_in_valid", + Box::new(|| (Box::new(Int64In { val: 3 }) as Box, 0)) as Factory, + ), + ( + "int64_in_invalid", + Box::new(|| (Box::new(Int64In { val: 5 }) as Box, 1)) as Factory, + ), + ( + "int64_not_in_valid", + Box::new(|| (Box::new(Int64NotIn { val: 1 }) as Box, 0)) as Factory, + ), + ( + "int64_not_in_invalid", + Box::new(|| (Box::new(Int64NotIn { val: 0 }) as Box, 1)) as Factory, + ), + ( + "int64_lt_valid", + Box::new(|| (Box::new(Int64Lt { val: -1 }) as Box, 0)) as Factory, + ), + ( + "int64_lt_invalid_equal", + Box::new(|| (Box::new(Int64Lt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "int64_lt_invalid", + Box::new(|| (Box::new(Int64Lt { val: 1 }) as Box, 1)) as Factory, + ), + ( + "int64_lte_valid", + Box::new(|| (Box::new(Int64Lte { val: 63 }) as Box, 0)) as Factory, + ), + ( + "int64_lte_valid_equal", + Box::new(|| (Box::new(Int64Lte { val: 64 }) as Box, 0)) as Factory, + ), + ( + "int64_lte_invalid", + Box::new(|| (Box::new(Int64Lte { val: 65 }) as Box, 1)) as Factory, + ), + ( + "int64_gt_valid", + Box::new(|| (Box::new(Int64Gt { val: 17 }) as Box, 0)) as Factory, + ), + ( + "int64_gt_invalid_equal", + Box::new(|| (Box::new(Int64Gt { val: 16 }) as Box, 1)) as Factory, + ), + ( + "int64_gt_invalid", + Box::new(|| (Box::new(Int64Gt { val: 15 }) as Box, 1)) as Factory, + ), + ( + "int64_gte_valid", + Box::new(|| (Box::new(Int64Gte { val: 9 }) as Box, 0)) as Factory, + ), + ( + "int64_gte_valid_equal", + Box::new(|| (Box::new(Int64Gte { val: 8 }) as Box, 0)) as Factory, + ), + ( + "int64_gte_invalid", + Box::new(|| (Box::new(Int64Gte { val: 7 }) as Box, 1)) as Factory, + ), + ( + "int64_gt_lt_valid", + Box::new(|| (Box::new(Int64Gtlt { val: 5 }) as Box, 0)) as Factory, + ), + ( + "int64_gt_lt_invalid_above", + Box::new(|| (Box::new(Int64Gtlt { val: 11 }) as Box, 1)) as Factory, + ), + ( + "int64_gt_lt_invalid_below", + Box::new(|| (Box::new(Int64Gtlt { val: -1 }) as Box, 1)) as Factory, + ), + ( + "int64_gt_lt_invalid_max", + Box::new(|| (Box::new(Int64Gtlt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "int64_gt_lt_invalid_min", + Box::new(|| (Box::new(Int64Gtlt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "int64_exclusive_gt_lt_valid_above", + Box::new(|| (Box::new(Int64ExLtgt { val: 11 }) as Box, 0)) as Factory, + ), + ( + "int64_exclusive_gt_lt_valid_below", + Box::new(|| (Box::new(Int64ExLtgt { val: -1 }) as Box, 0)) as Factory, + ), + ( + "int64_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(Int64ExLtgt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "int64_exclusive_gt_lt_invalid_max", + Box::new(|| (Box::new(Int64ExLtgt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "int64_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(Int64ExLtgt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "int64_gte_lte_valid", + Box::new(|| (Box::new(Int64Gtelte { val: 200 }) as Box, 0)) as Factory, + ), + ( + "int64_gte_lte_valid_max", + Box::new(|| (Box::new(Int64Gtelte { val: 256 }) as Box, 0)) as Factory, + ), + ( + "int64_gte_lte_valid_min", + Box::new(|| (Box::new(Int64Gtelte { val: 128 }) as Box, 0)) as Factory, + ), + ( + "int64_gte_lte_invalid_above", + Box::new(|| (Box::new(Int64Gtelte { val: 300 }) as Box, 1)) as Factory, + ), + ( + "int64_gte_lte_invalid_below", + Box::new(|| (Box::new(Int64Gtelte { val: 100 }) as Box, 1)) as Factory, + ), + ( + "int64_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(Int64ExGtelte { val: 300 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "int64_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(Int64ExGtelte { val: 100 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "int64_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(Int64ExGtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "int64_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(Int64ExGtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "int64_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(Int64ExGtelte { val: 200 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "int64_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(Int64Ignore { val: 0 }) as Box, 0)) as Factory, + ), + ( + "int64_optional_lte_valid", + Box::new(|| { + ( + Box::new(Int64LteOptional { val: Some(63) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "int64_optional_lte_valid_equal", + Box::new(|| { + ( + Box::new(Int64LteOptional { val: Some(64) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "int64_optional_lte_valid_unset", + Box::new(|| { + ( + Box::new(Int64LteOptional { val: None }) as Box, + 0, + ) + }) as Factory, + ), + ( + "uint32_none_valid", + Box::new(|| (Box::new(UInt32None { val: 123 }) as Box, 0)) as Factory, + ), + ( + "uint32_const_valid", + Box::new(|| (Box::new(UInt32Const { val: 1 }) as Box, 0)) as Factory, + ), + ( + "uint32_const_invalid", + Box::new(|| (Box::new(UInt32Const { val: 2 }) as Box, 1)) as Factory, + ), + ( + "uint32_in_valid", + Box::new(|| (Box::new(UInt32In { val: 3 }) as Box, 0)) as Factory, + ), + ( + "uint32_in_invalid", + Box::new(|| (Box::new(UInt32In { val: 5 }) as Box, 1)) as Factory, + ), + ( + "uint32_not_in_valid", + Box::new(|| (Box::new(UInt32NotIn { val: 1 }) as Box, 0)) as Factory, + ), + ( + "uint32_not_in_invalid", + Box::new(|| (Box::new(UInt32NotIn { val: 0 }) as Box, 1)) as Factory, + ), + ( + "uint32_lt_valid", + Box::new(|| (Box::new(UInt32Lt { val: 4 }) as Box, 0)) as Factory, + ), + ( + "uint32_lt_invalid_equal", + Box::new(|| (Box::new(UInt32Lt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "uint32_lt_invalid", + Box::new(|| (Box::new(UInt32Lt { val: 6 }) as Box, 1)) as Factory, + ), + ( + "uint32_lte_valid", + Box::new(|| (Box::new(UInt32Lte { val: 63 }) as Box, 0)) as Factory, + ), + ( + "uint32_lte_valid_equal", + Box::new(|| (Box::new(UInt32Lte { val: 64 }) as Box, 0)) as Factory, + ), + ( + "uint32_lte_invalid", + Box::new(|| (Box::new(UInt32Lte { val: 65 }) as Box, 1)) as Factory, + ), + ( + "uint32_gt_valid", + Box::new(|| (Box::new(UInt32Gt { val: 17 }) as Box, 0)) as Factory, + ), + ( + "uint32_gt_invalid_equal", + Box::new(|| (Box::new(UInt32Gt { val: 16 }) as Box, 1)) as Factory, + ), + ( + "uint32_gt_invalid", + Box::new(|| (Box::new(UInt32Gt { val: 15 }) as Box, 1)) as Factory, + ), + ( + "uint32_gte_valid", + Box::new(|| (Box::new(UInt32Gte { val: 9 }) as Box, 0)) as Factory, + ), + ( + "uint32_gte_valid_equal", + Box::new(|| (Box::new(UInt32Gte { val: 8 }) as Box, 0)) as Factory, + ), + ( + "uint32_gte_invalid", + Box::new(|| (Box::new(UInt32Gte { val: 7 }) as Box, 1)) as Factory, + ), + ( + "uint32_gt_lt_valid", + Box::new(|| (Box::new(UInt32Gtlt { val: 7 }) as Box, 0)) as Factory, + ), + ( + "uint32_gt_lt_invalid_above", + Box::new(|| (Box::new(UInt32Gtlt { val: 11 }) as Box, 1)) as Factory, + ), + ( + "uint32_gt_lt_invalid_below", + Box::new(|| (Box::new(UInt32Gtlt { val: 1 }) as Box, 1)) as Factory, + ), + ( + "uint32_gt_lt_invalid_max", + Box::new(|| (Box::new(UInt32Gtlt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "uint32_gt_lt_invalid_min", + Box::new(|| (Box::new(UInt32Gtlt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "uint32_exclusive_gt_lt_valid_above", + Box::new(|| (Box::new(UInt32ExLtgt { val: 11 }) as Box, 0)) as Factory, + ), + ( + "uint32_exclusive_gt_lt_valid_below", + Box::new(|| (Box::new(UInt32ExLtgt { val: 4 }) as Box, 0)) as Factory, + ), + ( + "uint32_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(UInt32ExLtgt { val: 7 }) as Box, 1)) as Factory, + ), + ( + "uint32_exclusive_gt_lt_invalid_max", + Box::new(|| (Box::new(UInt32ExLtgt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "uint32_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(UInt32ExLtgt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "uint32_gte_lte_valid", + Box::new(|| (Box::new(UInt32Gtelte { val: 200 }) as Box, 0)) as Factory, + ), + ( + "uint32_gte_lte_valid_max", + Box::new(|| (Box::new(UInt32Gtelte { val: 256 }) as Box, 0)) as Factory, + ), + ( + "uint32_gte_lte_valid_min", + Box::new(|| (Box::new(UInt32Gtelte { val: 128 }) as Box, 0)) as Factory, + ), + ( + "uint32_gte_lte_invalid_above", + Box::new(|| (Box::new(UInt32Gtelte { val: 300 }) as Box, 1)) as Factory, + ), + ( + "uint32_gte_lte_invalid_below", + Box::new(|| (Box::new(UInt32Gtelte { val: 100 }) as Box, 1)) as Factory, + ), + ( + "uint32_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(UInt32ExGtelte { val: 300 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "uint32_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(UInt32ExGtelte { val: 100 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "uint32_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(UInt32ExGtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "uint32_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(UInt32ExGtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "uint32_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(UInt32ExGtelte { val: 200 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "uint32_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(UInt32Ignore { val: 0 }) as Box, 0)) as Factory, + ), + ( + "uint64_none_valid", + Box::new(|| (Box::new(UInt64None { val: 123 }) as Box, 0)) as Factory, + ), + ( + "uint64_const_valid", + Box::new(|| (Box::new(UInt64Const { val: 1 }) as Box, 0)) as Factory, + ), + ( + "uint64_const_invalid", + Box::new(|| (Box::new(UInt64Const { val: 2 }) as Box, 1)) as Factory, + ), + ( + "uint64_in_valid", + Box::new(|| (Box::new(UInt64In { val: 3 }) as Box, 0)) as Factory, + ), + ( + "uint64_in_invalid", + Box::new(|| (Box::new(UInt64In { val: 5 }) as Box, 1)) as Factory, + ), + ( + "uint64_not_in_valid", + Box::new(|| (Box::new(UInt64NotIn { val: 1 }) as Box, 0)) as Factory, + ), + ( + "uint64_not_in_invalid", + Box::new(|| (Box::new(UInt64NotIn { val: 0 }) as Box, 1)) as Factory, + ), + ( + "uint64_lt_valid", + Box::new(|| (Box::new(UInt64Lt { val: 4 }) as Box, 0)) as Factory, + ), + ( + "uint64_lt_invalid_equal", + Box::new(|| (Box::new(UInt64Lt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "uint64_lt_invalid", + Box::new(|| (Box::new(UInt64Lt { val: 6 }) as Box, 1)) as Factory, + ), + ( + "uint64_lte_valid", + Box::new(|| (Box::new(UInt64Lte { val: 63 }) as Box, 0)) as Factory, + ), + ( + "uint64_lte_valid_equal", + Box::new(|| (Box::new(UInt64Lte { val: 64 }) as Box, 0)) as Factory, + ), + ( + "uint64_lte_invalid", + Box::new(|| (Box::new(UInt64Lte { val: 65 }) as Box, 1)) as Factory, + ), + ( + "uint64_gt_valid", + Box::new(|| (Box::new(UInt64Gt { val: 17 }) as Box, 0)) as Factory, + ), + ( + "uint64_gt_invalid_equal", + Box::new(|| (Box::new(UInt64Gt { val: 16 }) as Box, 1)) as Factory, + ), + ( + "uint64_gt_invalid", + Box::new(|| (Box::new(UInt64Gt { val: 15 }) as Box, 1)) as Factory, + ), + ( + "uint64_gte_valid", + Box::new(|| (Box::new(UInt64Gte { val: 9 }) as Box, 0)) as Factory, + ), + ( + "uint64_gte_valid_equal", + Box::new(|| (Box::new(UInt64Gte { val: 8 }) as Box, 0)) as Factory, + ), + ( + "uint64_gte_invalid", + Box::new(|| (Box::new(UInt64Gte { val: 7 }) as Box, 1)) as Factory, + ), + ( + "uint64_gt_lt_valid", + Box::new(|| (Box::new(UInt64Gtlt { val: 7 }) as Box, 0)) as Factory, + ), + ( + "uint64_gt_lt_invalid_above", + Box::new(|| (Box::new(UInt64Gtlt { val: 11 }) as Box, 1)) as Factory, + ), + ( + "uint64_gt_lt_invalid_below", + Box::new(|| (Box::new(UInt64Gtlt { val: 1 }) as Box, 1)) as Factory, + ), + ( + "uint64_gt_lt_invalid_max", + Box::new(|| (Box::new(UInt64Gtlt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "uint64_gt_lt_invalid_min", + Box::new(|| (Box::new(UInt64Gtlt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "uint64_exclusive_gt_lt_valid_above", + Box::new(|| (Box::new(UInt64ExLtgt { val: 11 }) as Box, 0)) as Factory, + ), + ( + "uint64_exclusive_gt_lt_valid_below", + Box::new(|| (Box::new(UInt64ExLtgt { val: 4 }) as Box, 0)) as Factory, + ), + ( + "uint64_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(UInt64ExLtgt { val: 7 }) as Box, 1)) as Factory, + ), + ( + "uint64_exclusive_gt_lt_invalid_max", + Box::new(|| (Box::new(UInt64ExLtgt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "uint64_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(UInt64ExLtgt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "uint64_gte_lte_valid", + Box::new(|| (Box::new(UInt64Gtelte { val: 200 }) as Box, 0)) as Factory, + ), + ( + "uint64_gte_lte_valid_max", + Box::new(|| (Box::new(UInt64Gtelte { val: 256 }) as Box, 0)) as Factory, + ), + ( + "uint64_gte_lte_valid_min", + Box::new(|| (Box::new(UInt64Gtelte { val: 128 }) as Box, 0)) as Factory, + ), + ( + "uint64_gte_lte_invalid_above", + Box::new(|| (Box::new(UInt64Gtelte { val: 300 }) as Box, 1)) as Factory, + ), + ( + "uint64_gte_lte_invalid_below", + Box::new(|| (Box::new(UInt64Gtelte { val: 100 }) as Box, 1)) as Factory, + ), + ( + "uint64_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(UInt64ExGtelte { val: 300 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "uint64_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(UInt64ExGtelte { val: 100 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "uint64_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(UInt64ExGtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "uint64_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(UInt64ExGtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "uint64_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(UInt64ExGtelte { val: 200 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "uint64_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(UInt64Ignore { val: 0 }) as Box, 0)) as Factory, + ), + ( + "sint32_none_valid", + Box::new(|| (Box::new(SInt32None { val: 123 }) as Box, 0)) as Factory, + ), + ( + "sint32_const_valid", + Box::new(|| (Box::new(SInt32Const { val: 1 }) as Box, 0)) as Factory, + ), + ( + "sint32_const_invalid", + Box::new(|| (Box::new(SInt32Const { val: 2 }) as Box, 1)) as Factory, + ), + ( + "sint32_in_valid", + Box::new(|| (Box::new(SInt32In { val: 3 }) as Box, 0)) as Factory, + ), + ( + "sint32_in_invalid", + Box::new(|| (Box::new(SInt32In { val: 5 }) as Box, 1)) as Factory, + ), + ( + "sint32_not_in_valid", + Box::new(|| (Box::new(SInt32NotIn { val: 1 }) as Box, 0)) as Factory, + ), + ( + "sint32_not_in_invalid", + Box::new(|| (Box::new(SInt32NotIn { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sint32_lt_valid", + Box::new(|| (Box::new(SInt32Lt { val: -1 }) as Box, 0)) as Factory, + ), + ( + "sint32_lt_invalid_equal", + Box::new(|| (Box::new(SInt32Lt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sint32_lt_invalid", + Box::new(|| (Box::new(SInt32Lt { val: 1 }) as Box, 1)) as Factory, + ), + ( + "sint32_lte_valid", + Box::new(|| (Box::new(SInt32Lte { val: 63 }) as Box, 0)) as Factory, + ), + ( + "sint32_lte_valid_equal", + Box::new(|| (Box::new(SInt32Lte { val: 64 }) as Box, 0)) as Factory, + ), + ( + "sint32_lte_invalid", + Box::new(|| (Box::new(SInt32Lte { val: 65 }) as Box, 1)) as Factory, + ), + ( + "sint32_gt_valid", + Box::new(|| (Box::new(SInt32Gt { val: 17 }) as Box, 0)) as Factory, + ), + ( + "sint32_gt_invalid_equal", + Box::new(|| (Box::new(SInt32Gt { val: 16 }) as Box, 1)) as Factory, + ), + ( + "sint32_gt_invalid", + Box::new(|| (Box::new(SInt32Gt { val: 15 }) as Box, 1)) as Factory, + ), + ( + "sint32_gte_valid", + Box::new(|| (Box::new(SInt32Gte { val: 9 }) as Box, 0)) as Factory, + ), + ( + "sint32_gte_valid_equal", + Box::new(|| (Box::new(SInt32Gte { val: 8 }) as Box, 0)) as Factory, + ), + ( + "sint32_gte_invalid", + Box::new(|| (Box::new(SInt32Gte { val: 7 }) as Box, 1)) as Factory, + ), + ( + "sint32_gt_lt_valid", + Box::new(|| (Box::new(SInt32Gtlt { val: 5 }) as Box, 0)) as Factory, + ), + ( + "sint32_gt_lt_invalid_above", + Box::new(|| (Box::new(SInt32Gtlt { val: 11 }) as Box, 1)) as Factory, + ), + ( + "sint32_gt_lt_invalid_below", + Box::new(|| (Box::new(SInt32Gtlt { val: -1 }) as Box, 1)) as Factory, + ), + ( + "sint32_gt_lt_invalid_max", + Box::new(|| (Box::new(SInt32Gtlt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "sint32_gt_lt_invalid_min", + Box::new(|| (Box::new(SInt32Gtlt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sint32_exclusive_gt_lt_valid_above", + Box::new(|| (Box::new(SInt32ExLtgt { val: 11 }) as Box, 0)) as Factory, + ), + ( + "sint32_exclusive_gt_lt_valid_below", + Box::new(|| (Box::new(SInt32ExLtgt { val: -1 }) as Box, 0)) as Factory, + ), + ( + "sint32_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(SInt32ExLtgt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "sint32_exclusive_gt_lt_invalid_max", + Box::new(|| (Box::new(SInt32ExLtgt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "sint32_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(SInt32ExLtgt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sint32_gte_lte_valid", + Box::new(|| (Box::new(SInt32Gtelte { val: 200 }) as Box, 0)) as Factory, + ), + ( + "sint32_gte_lte_valid_max", + Box::new(|| (Box::new(SInt32Gtelte { val: 256 }) as Box, 0)) as Factory, + ), + ( + "sint32_gte_lte_valid_min", + Box::new(|| (Box::new(SInt32Gtelte { val: 128 }) as Box, 0)) as Factory, + ), + ( + "sint32_gte_lte_invalid_above", + Box::new(|| (Box::new(SInt32Gtelte { val: 300 }) as Box, 1)) as Factory, + ), + ( + "sint32_gte_lte_invalid_below", + Box::new(|| (Box::new(SInt32Gtelte { val: 100 }) as Box, 1)) as Factory, + ), + ( + "sint32_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(SInt32ExGtelte { val: 300 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sint32_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(SInt32ExGtelte { val: 100 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sint32_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(SInt32ExGtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sint32_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(SInt32ExGtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sint32_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(SInt32ExGtelte { val: 200 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "sint32_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(SInt32Ignore { val: 0 }) as Box, 0)) as Factory, + ), + ( + "sint64_none_valid", + Box::new(|| (Box::new(SInt64None { val: 123 }) as Box, 0)) as Factory, + ), + ( + "sint64_const_valid", + Box::new(|| (Box::new(SInt64Const { val: 1 }) as Box, 0)) as Factory, + ), + ( + "sint64_const_invalid", + Box::new(|| (Box::new(SInt64Const { val: 2 }) as Box, 1)) as Factory, + ), + ( + "sint64_in_valid", + Box::new(|| (Box::new(SInt64In { val: 3 }) as Box, 0)) as Factory, + ), + ( + "sint64_in_invalid", + Box::new(|| (Box::new(SInt64In { val: 5 }) as Box, 1)) as Factory, + ), + ( + "sint64_not_in_valid", + Box::new(|| (Box::new(SInt64NotIn { val: 1 }) as Box, 0)) as Factory, + ), + ( + "sint64_not_in_invalid", + Box::new(|| (Box::new(SInt64NotIn { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sint64_lt_valid", + Box::new(|| (Box::new(SInt64Lt { val: -1 }) as Box, 0)) as Factory, + ), + ( + "sint64_lt_invalid_equal", + Box::new(|| (Box::new(SInt64Lt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sint64_lt_invalid", + Box::new(|| (Box::new(SInt64Lt { val: 1 }) as Box, 1)) as Factory, + ), + ( + "sint64_lte_valid", + Box::new(|| (Box::new(SInt64Lte { val: 63 }) as Box, 0)) as Factory, + ), + ( + "sint64_lte_valid_equal", + Box::new(|| (Box::new(SInt64Lte { val: 64 }) as Box, 0)) as Factory, + ), + ( + "sint64_lte_invalid", + Box::new(|| (Box::new(SInt64Lte { val: 65 }) as Box, 1)) as Factory, + ), + ( + "sint64_gt_valid", + Box::new(|| (Box::new(SInt64Gt { val: 17 }) as Box, 0)) as Factory, + ), + ( + "sint64_gt_invalid_equal", + Box::new(|| (Box::new(SInt64Gt { val: 16 }) as Box, 1)) as Factory, + ), + ( + "sint64_gt_invalid", + Box::new(|| (Box::new(SInt64Gt { val: 15 }) as Box, 1)) as Factory, + ), + ( + "sint64_gte_valid", + Box::new(|| (Box::new(SInt64Gte { val: 9 }) as Box, 0)) as Factory, + ), + ( + "sint64_gte_valid_equal", + Box::new(|| (Box::new(SInt64Gte { val: 8 }) as Box, 0)) as Factory, + ), + ( + "sint64_gte_invalid", + Box::new(|| (Box::new(SInt64Gte { val: 7 }) as Box, 1)) as Factory, + ), + ( + "sint64_gt_lt_valid", + Box::new(|| (Box::new(SInt64Gtlt { val: 5 }) as Box, 0)) as Factory, + ), + ( + "sint64_gt_lt_invalid_above", + Box::new(|| (Box::new(SInt64Gtlt { val: 11 }) as Box, 1)) as Factory, + ), + ( + "sint64_gt_lt_invalid_below", + Box::new(|| (Box::new(SInt64Gtlt { val: -1 }) as Box, 1)) as Factory, + ), + ( + "sint64_gt_lt_invalid_max", + Box::new(|| (Box::new(SInt64Gtlt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "sint64_gt_lt_invalid_min", + Box::new(|| (Box::new(SInt64Gtlt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sint64_exclusive_gt_lt_valid_above", + Box::new(|| (Box::new(SInt64ExLtgt { val: 11 }) as Box, 0)) as Factory, + ), + ( + "sint64_exclusive_gt_lt_valid_below", + Box::new(|| (Box::new(SInt64ExLtgt { val: -1 }) as Box, 0)) as Factory, + ), + ( + "sint64_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(SInt64ExLtgt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "sint64_exclusive_gt_lt_invalid_max", + Box::new(|| (Box::new(SInt64ExLtgt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "sint64_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(SInt64ExLtgt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sint64_gte_lte_valid", + Box::new(|| (Box::new(SInt64Gtelte { val: 200 }) as Box, 0)) as Factory, + ), + ( + "sint64_gte_lte_valid_max", + Box::new(|| (Box::new(SInt64Gtelte { val: 256 }) as Box, 0)) as Factory, + ), + ( + "sint64_gte_lte_valid_min", + Box::new(|| (Box::new(SInt64Gtelte { val: 128 }) as Box, 0)) as Factory, + ), + ( + "sint64_gte_lte_invalid_above", + Box::new(|| (Box::new(SInt64Gtelte { val: 300 }) as Box, 1)) as Factory, + ), + ( + "sint64_gte_lte_invalid_below", + Box::new(|| (Box::new(SInt64Gtelte { val: 100 }) as Box, 1)) as Factory, + ), + ( + "sint64_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(SInt64ExGtelte { val: 300 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sint64_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(SInt64ExGtelte { val: 100 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sint64_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(SInt64ExGtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sint64_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(SInt64ExGtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sint64_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(SInt64ExGtelte { val: 200 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "sint64_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(SInt64Ignore { val: 0 }) as Box, 0)) as Factory, + ), + ( + "fixed32_none_valid", + Box::new(|| (Box::new(Fixed32None { val: 123 }) as Box, 0)) as Factory, + ), + ( + "fixed32_const_valid", + Box::new(|| (Box::new(Fixed32Const { val: 1 }) as Box, 0)) as Factory, + ), + ( + "fixed32_const_invalid", + Box::new(|| (Box::new(Fixed32Const { val: 2 }) as Box, 1)) as Factory, + ), + ( + "fixed32_in_valid", + Box::new(|| (Box::new(Fixed32In { val: 3 }) as Box, 0)) as Factory, + ), + ( + "fixed32_in_invalid", + Box::new(|| (Box::new(Fixed32In { val: 5 }) as Box, 1)) as Factory, + ), + ( + "fixed32_not_in_valid", + Box::new(|| (Box::new(Fixed32NotIn { val: 1 }) as Box, 0)) as Factory, + ), + ( + "fixed32_not_in_invalid", + Box::new(|| (Box::new(Fixed32NotIn { val: 0 }) as Box, 1)) as Factory, + ), + ( + "fixed32_lt_valid", + Box::new(|| (Box::new(Fixed32Lt { val: 4 }) as Box, 0)) as Factory, + ), + ( + "fixed32_lt_invalid_equal", + Box::new(|| (Box::new(Fixed32Lt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "fixed32_lt_invalid", + Box::new(|| (Box::new(Fixed32Lt { val: 6 }) as Box, 1)) as Factory, + ), + ( + "fixed32_lte_valid", + Box::new(|| (Box::new(Fixed32Lte { val: 63 }) as Box, 0)) as Factory, + ), + ( + "fixed32_lte_valid_equal", + Box::new(|| (Box::new(Fixed32Lte { val: 64 }) as Box, 0)) as Factory, + ), + ( + "fixed32_lte_invalid", + Box::new(|| (Box::new(Fixed32Lte { val: 65 }) as Box, 1)) as Factory, + ), + ( + "fixed32_gt_valid", + Box::new(|| (Box::new(Fixed32Gt { val: 17 }) as Box, 0)) as Factory, + ), + ( + "fixed32_gt_invalid_equal", + Box::new(|| (Box::new(Fixed32Gt { val: 16 }) as Box, 1)) as Factory, + ), + ( + "fixed32_gt_invalid", + Box::new(|| (Box::new(Fixed32Gt { val: 15 }) as Box, 1)) as Factory, + ), + ( + "fixed32_gte_valid", + Box::new(|| (Box::new(Fixed32Gte { val: 9 }) as Box, 0)) as Factory, + ), + ( + "fixed32_gte_valid_equal", + Box::new(|| (Box::new(Fixed32Gte { val: 8 }) as Box, 0)) as Factory, + ), + ( + "fixed32_gte_invalid", + Box::new(|| (Box::new(Fixed32Gte { val: 7 }) as Box, 1)) as Factory, + ), + ( + "fixed32_gt_lt_valid", + Box::new(|| (Box::new(Fixed32Gtlt { val: 7 }) as Box, 0)) as Factory, + ), + ( + "fixed32_gt_lt_invalid_above", + Box::new(|| (Box::new(Fixed32Gtlt { val: 11 }) as Box, 1)) as Factory, + ), + ( + "fixed32_gt_lt_invalid_below", + Box::new(|| (Box::new(Fixed32Gtlt { val: 1 }) as Box, 1)) as Factory, + ), + ( + "fixed32_gt_lt_invalid_max", + Box::new(|| (Box::new(Fixed32Gtlt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "fixed32_gt_lt_invalid_min", + Box::new(|| (Box::new(Fixed32Gtlt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "fixed32_exclusive_gt_lt_valid_above", + Box::new(|| (Box::new(Fixed32ExLtgt { val: 11 }) as Box, 0)) as Factory, + ), + ( + "fixed32_exclusive_gt_lt_valid_below", + Box::new(|| (Box::new(Fixed32ExLtgt { val: 4 }) as Box, 0)) as Factory, + ), + ( + "fixed32_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(Fixed32ExLtgt { val: 7 }) as Box, 1)) as Factory, + ), + ( + "fixed32_exclusive_gt_lt_invalid_max", + Box::new(|| (Box::new(Fixed32ExLtgt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "fixed32_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(Fixed32ExLtgt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "fixed32_gte_lte_valid", + Box::new(|| { + ( + Box::new(Fixed32Gtelte { val: 200 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed32_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(Fixed32Gtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed32_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(Fixed32Gtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed32_gte_lte_invalid_above", + Box::new(|| { + ( + Box::new(Fixed32Gtelte { val: 300 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "fixed32_gte_lte_invalid_below", + Box::new(|| { + ( + Box::new(Fixed32Gtelte { val: 100 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "fixed32_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(Fixed32ExGtelte { val: 300 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed32_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(Fixed32ExGtelte { val: 100 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed32_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(Fixed32ExGtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed32_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(Fixed32ExGtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed32_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(Fixed32ExGtelte { val: 200 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "fixed32_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(Fixed32Ignore { val: 0 }) as Box, 0)) as Factory, + ), + ( + "fixed64_none_valid", + Box::new(|| (Box::new(Fixed64None { val: 123 }) as Box, 0)) as Factory, + ), + ( + "fixed64_const_valid", + Box::new(|| (Box::new(Fixed64Const { val: 1 }) as Box, 0)) as Factory, + ), + ( + "fixed64_const_invalid", + Box::new(|| (Box::new(Fixed64Const { val: 2 }) as Box, 1)) as Factory, + ), + ( + "fixed64_in_valid", + Box::new(|| (Box::new(Fixed64In { val: 3 }) as Box, 0)) as Factory, + ), + ( + "fixed64_in_invalid", + Box::new(|| (Box::new(Fixed64In { val: 5 }) as Box, 1)) as Factory, + ), + ( + "fixed64_not_in_valid", + Box::new(|| (Box::new(Fixed64NotIn { val: 1 }) as Box, 0)) as Factory, + ), + ( + "fixed64_not_in_invalid", + Box::new(|| (Box::new(Fixed64NotIn { val: 0 }) as Box, 1)) as Factory, + ), + ( + "fixed64_lt_valid", + Box::new(|| (Box::new(Fixed64Lt { val: 4 }) as Box, 0)) as Factory, + ), + ( + "fixed64_lt_invalid_equal", + Box::new(|| (Box::new(Fixed64Lt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "fixed64_lt_invalid", + Box::new(|| (Box::new(Fixed64Lt { val: 6 }) as Box, 1)) as Factory, + ), + ( + "fixed64_lte_valid", + Box::new(|| (Box::new(Fixed64Lte { val: 63 }) as Box, 0)) as Factory, + ), + ( + "fixed64_lte_valid_equal", + Box::new(|| (Box::new(Fixed64Lte { val: 64 }) as Box, 0)) as Factory, + ), + ( + "fixed64_lte_invalid", + Box::new(|| (Box::new(Fixed64Lte { val: 65 }) as Box, 1)) as Factory, + ), + ( + "fixed64_gt_valid", + Box::new(|| (Box::new(Fixed64Gt { val: 17 }) as Box, 0)) as Factory, + ), + ( + "fixed64_gt_invalid_equal", + Box::new(|| (Box::new(Fixed64Gt { val: 16 }) as Box, 1)) as Factory, + ), + ( + "fixed64_gt_invalid", + Box::new(|| (Box::new(Fixed64Gt { val: 15 }) as Box, 1)) as Factory, + ), + ( + "fixed64_gte_valid", + Box::new(|| (Box::new(Fixed64Gte { val: 9 }) as Box, 0)) as Factory, + ), + ( + "fixed64_gte_valid_equal", + Box::new(|| (Box::new(Fixed64Gte { val: 8 }) as Box, 0)) as Factory, + ), + ( + "fixed64_gte_invalid", + Box::new(|| (Box::new(Fixed64Gte { val: 7 }) as Box, 1)) as Factory, + ), + ( + "fixed64_gt_lt_valid", + Box::new(|| (Box::new(Fixed64Gtlt { val: 7 }) as Box, 0)) as Factory, + ), + ( + "fixed64_gt_lt_invalid_above", + Box::new(|| (Box::new(Fixed64Gtlt { val: 11 }) as Box, 1)) as Factory, + ), + ( + "fixed64_gt_lt_invalid_below", + Box::new(|| (Box::new(Fixed64Gtlt { val: 1 }) as Box, 1)) as Factory, + ), + ( + "fixed64_gt_lt_invalid_max", + Box::new(|| (Box::new(Fixed64Gtlt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "fixed64_gt_lt_invalid_min", + Box::new(|| (Box::new(Fixed64Gtlt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "fixed64_exclusive_gt_lt_valid_above", + Box::new(|| (Box::new(Fixed64ExLtgt { val: 11 }) as Box, 0)) as Factory, + ), + ( + "fixed64_exclusive_gt_lt_valid_below", + Box::new(|| (Box::new(Fixed64ExLtgt { val: 4 }) as Box, 0)) as Factory, + ), + ( + "fixed64_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(Fixed64ExLtgt { val: 7 }) as Box, 1)) as Factory, + ), + ( + "fixed64_exclusive_gt_lt_invalid_max", + Box::new(|| (Box::new(Fixed64ExLtgt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "fixed64_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(Fixed64ExLtgt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "fixed64_gte_lte_valid", + Box::new(|| { + ( + Box::new(Fixed64Gtelte { val: 200 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed64_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(Fixed64Gtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed64_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(Fixed64Gtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed64_gte_lte_invalid_above", + Box::new(|| { + ( + Box::new(Fixed64Gtelte { val: 300 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "fixed64_gte_lte_invalid_below", + Box::new(|| { + ( + Box::new(Fixed64Gtelte { val: 100 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "fixed64_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(Fixed64ExGtelte { val: 300 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed64_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(Fixed64ExGtelte { val: 100 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed64_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(Fixed64ExGtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed64_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(Fixed64ExGtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "fixed64_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(Fixed64ExGtelte { val: 200 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "fixed64_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(Fixed64Ignore { val: 0 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_none_valid", + Box::new(|| (Box::new(SFixed32None { val: 123 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_const_valid", + Box::new(|| (Box::new(SFixed32Const { val: 1 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_const_invalid", + Box::new(|| (Box::new(SFixed32Const { val: 2 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_in_valid", + Box::new(|| (Box::new(SFixed32In { val: 3 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_in_invalid", + Box::new(|| (Box::new(SFixed32In { val: 5 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_not_in_valid", + Box::new(|| (Box::new(SFixed32NotIn { val: 1 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_not_in_invalid", + Box::new(|| (Box::new(SFixed32NotIn { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_lt_valid", + Box::new(|| (Box::new(SFixed32Lt { val: -1 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_lt_invalid_equal", + Box::new(|| (Box::new(SFixed32Lt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_lt_invalid", + Box::new(|| (Box::new(SFixed32Lt { val: 1 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_lte_valid", + Box::new(|| (Box::new(SFixed32Lte { val: 63 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_lte_valid_equal", + Box::new(|| (Box::new(SFixed32Lte { val: 64 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_lte_invalid", + Box::new(|| (Box::new(SFixed32Lte { val: 65 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_gt_valid", + Box::new(|| (Box::new(SFixed32Gt { val: 17 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_gt_invalid_equal", + Box::new(|| (Box::new(SFixed32Gt { val: 16 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_gt_invalid", + Box::new(|| (Box::new(SFixed32Gt { val: 15 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_gte_valid", + Box::new(|| (Box::new(SFixed32Gte { val: 9 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_gte_valid_equal", + Box::new(|| (Box::new(SFixed32Gte { val: 8 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_gte_invalid", + Box::new(|| (Box::new(SFixed32Gte { val: 7 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_gt_lt_valid", + Box::new(|| (Box::new(SFixed32Gtlt { val: 5 }) as Box, 0)) as Factory, + ), + ( + "sfixed32_gt_lt_invalid_above", + Box::new(|| (Box::new(SFixed32Gtlt { val: 11 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_gt_lt_invalid_below", + Box::new(|| (Box::new(SFixed32Gtlt { val: -1 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_gt_lt_invalid_max", + Box::new(|| (Box::new(SFixed32Gtlt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_gt_lt_invalid_min", + Box::new(|| (Box::new(SFixed32Gtlt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_exclusive_gt_lt_valid_above", + Box::new(|| { + ( + Box::new(SFixed32ExLtgt { val: 11 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed32_exclusive_gt_lt_valid_below", + Box::new(|| { + ( + Box::new(SFixed32ExLtgt { val: -1 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed32_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(SFixed32ExLtgt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_exclusive_gt_lt_invalid_max", + Box::new(|| { + ( + Box::new(SFixed32ExLtgt { val: 10 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "sfixed32_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(SFixed32ExLtgt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sfixed32_gte_lte_valid", + Box::new(|| { + ( + Box::new(SFixed32Gtelte { val: 200 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed32_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(SFixed32Gtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed32_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(SFixed32Gtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed32_gte_lte_invalid_above", + Box::new(|| { + ( + Box::new(SFixed32Gtelte { val: 300 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "sfixed32_gte_lte_invalid_below", + Box::new(|| { + ( + Box::new(SFixed32Gtelte { val: 100 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "sfixed32_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(SFixed32ExGtelte { val: 300 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed32_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(SFixed32ExGtelte { val: 100 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed32_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(SFixed32ExGtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed32_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(SFixed32ExGtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed32_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(SFixed32ExGtelte { val: 200 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "sfixed32_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(SFixed32Ignore { val: 0 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_none_valid", + Box::new(|| (Box::new(SFixed64None { val: 123 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_const_valid", + Box::new(|| (Box::new(SFixed64Const { val: 1 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_const_invalid", + Box::new(|| (Box::new(SFixed64Const { val: 2 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_in_valid", + Box::new(|| (Box::new(SFixed64In { val: 3 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_in_invalid", + Box::new(|| (Box::new(SFixed64In { val: 5 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_not_in_valid", + Box::new(|| (Box::new(SFixed64NotIn { val: 1 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_not_in_invalid", + Box::new(|| (Box::new(SFixed64NotIn { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_lt_valid", + Box::new(|| (Box::new(SFixed64Lt { val: -1 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_lt_invalid_equal", + Box::new(|| (Box::new(SFixed64Lt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_lt_invalid", + Box::new(|| (Box::new(SFixed64Lt { val: 1 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_lte_valid", + Box::new(|| (Box::new(SFixed64Lte { val: 63 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_lte_valid_equal", + Box::new(|| (Box::new(SFixed64Lte { val: 64 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_lte_invalid", + Box::new(|| (Box::new(SFixed64Lte { val: 65 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_gt_valid", + Box::new(|| (Box::new(SFixed64Gt { val: 17 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_gt_invalid_equal", + Box::new(|| (Box::new(SFixed64Gt { val: 16 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_gt_invalid", + Box::new(|| (Box::new(SFixed64Gt { val: 15 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_gte_valid", + Box::new(|| (Box::new(SFixed64Gte { val: 9 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_gte_valid_equal", + Box::new(|| (Box::new(SFixed64Gte { val: 8 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_gte_invalid", + Box::new(|| (Box::new(SFixed64Gte { val: 7 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_gt_lt_valid", + Box::new(|| (Box::new(SFixed64Gtlt { val: 5 }) as Box, 0)) as Factory, + ), + ( + "sfixed64_gt_lt_invalid_above", + Box::new(|| (Box::new(SFixed64Gtlt { val: 11 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_gt_lt_invalid_below", + Box::new(|| (Box::new(SFixed64Gtlt { val: -1 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_gt_lt_invalid_max", + Box::new(|| (Box::new(SFixed64Gtlt { val: 10 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_gt_lt_invalid_min", + Box::new(|| (Box::new(SFixed64Gtlt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_exclusive_gt_lt_valid_above", + Box::new(|| { + ( + Box::new(SFixed64ExLtgt { val: 11 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed64_exclusive_gt_lt_valid_below", + Box::new(|| { + ( + Box::new(SFixed64ExLtgt { val: -1 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed64_exclusive_gt_lt_invalid", + Box::new(|| (Box::new(SFixed64ExLtgt { val: 5 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_exclusive_gt_lt_invalid_max", + Box::new(|| { + ( + Box::new(SFixed64ExLtgt { val: 10 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "sfixed64_exclusive_gt_lt_invalid_min", + Box::new(|| (Box::new(SFixed64ExLtgt { val: 0 }) as Box, 1)) as Factory, + ), + ( + "sfixed64_gte_lte_valid", + Box::new(|| { + ( + Box::new(SFixed64Gtelte { val: 200 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed64_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(SFixed64Gtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed64_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(SFixed64Gtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed64_gte_lte_invalid_above", + Box::new(|| { + ( + Box::new(SFixed64Gtelte { val: 300 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "sfixed64_gte_lte_invalid_below", + Box::new(|| { + ( + Box::new(SFixed64Gtelte { val: 100 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "sfixed64_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(SFixed64ExGtelte { val: 300 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed64_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(SFixed64ExGtelte { val: 100 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed64_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(SFixed64ExGtelte { val: 256 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed64_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(SFixed64ExGtelte { val: 128 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "sfixed64_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(SFixed64ExGtelte { val: 200 }) as Box, + 1, + ) + }) as Factory, + ), + ( + "sfixed64_ignore_empty_gte_lte_valid", + Box::new(|| (Box::new(SFixed64Ignore { val: 0 }) as Box, 0)) as Factory, + ), + ( + "bool_none_valid", + Box::new(|| (Box::new(BoolNone { val: true }) as Box, 0)) as Factory, + ), + ( + "bool_const_true_valid", + Box::new(|| { + ( + Box::new(BoolConstTrue { val: true }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bool_const_true_invalid", + Box::new(|| { + ( + Box::new(BoolConstTrue { val: false }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bool_const_false_valid", + Box::new(|| { + ( + Box::new(BoolConstFalse { val: false }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bool_const_false_invalid", + Box::new(|| { + ( + Box::new(BoolConstFalse { val: true }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_none_valid", + Box::new(|| { + ( + Box::new(StringNone { + val: "quux".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_const_valid", + Box::new(|| { + ( + Box::new(StringConst { + val: "foo".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_const_invalid", + Box::new(|| { + ( + Box::new(StringConst { + val: "bar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_in_valid", + Box::new(|| { + ( + Box::new(StringIn { + val: "bar".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_in_invalid", + Box::new(|| { + ( + Box::new(StringIn { + val: "quux".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_not_in_valid", + Box::new(|| { + ( + Box::new(StringNotIn { + val: "quux".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_not_in_invalid", + Box::new(|| { + ( + Box::new(StringNotIn { + val: "fizz".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_len_valid", + Box::new(|| { + ( + Box::new(StringLen { + val: "baz".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_len_valid_multibyte", + Box::new(|| { + ( + Box::new(StringLen { + val: "你好吖".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_len_invalid_lt", + Box::new(|| { + ( + Box::new(StringLen { + val: "go".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_len_invalid_gt", + Box::new(|| { + ( + Box::new(StringLen { + val: "fizz".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_len_invalid_multibyte", + Box::new(|| { + ( + Box::new(StringLen { + val: "你好".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_min_len_valid", + Box::new(|| { + ( + Box::new(StringMinLen { + val: "protoc".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_len_valid_min", + Box::new(|| { + ( + Box::new(StringMinLen { + val: "baz".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_len_invalid", + Box::new(|| { + ( + Box::new(StringMinLen { + val: "go".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_min_len_invalid_multibyte", + Box::new(|| { + ( + Box::new(StringMinLen { + val: "你好".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_max_len_valid", + Box::new(|| { + ( + Box::new(StringMaxLen { + val: "foo".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_max_len_valid_max", + Box::new(|| { + ( + Box::new(StringMaxLen { + val: "proto".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_max_len_valid_multibyte", + Box::new(|| { + ( + Box::new(StringMaxLen { + val: "你好你好".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_max_len_invalid", + Box::new(|| { + ( + Box::new(StringMaxLen { + val: "1234567890".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_min_max_len_valid", + Box::new(|| { + ( + Box::new(StringMinMaxLen { + val: "quux".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_max_len_valid_min", + Box::new(|| { + ( + Box::new(StringMinMaxLen { + val: "foo".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_max_len_valid_max", + Box::new(|| { + ( + Box::new(StringMinMaxLen { + val: "proto".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_max_len_valid_multibyte", + Box::new(|| { + ( + Box::new(StringMinMaxLen { + val: "你好你好".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_max_len_invalid_below", + Box::new(|| { + ( + Box::new(StringMinMaxLen { + val: "go".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_min_max_len_invalid_above", + Box::new(|| { + ( + Box::new(StringMinMaxLen { + val: "validate".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_equal_min_max_len_valid", + Box::new(|| { + ( + Box::new(StringEqualMinMaxLen { + val: "proto".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_equal_min_max_len_invalid", + Box::new(|| { + ( + Box::new(StringEqualMinMaxLen { + val: "validate".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_len_bytes_valid", + Box::new(|| { + ( + Box::new(StringLenBytes { + val: "pace".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_len_bytes_invalid_lt", + Box::new(|| { + ( + Box::new(StringLenBytes { + val: "val".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_len_bytes_invalid_gt", + Box::new(|| { + ( + Box::new(StringLenBytes { + val: "world".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_len_bytes_invalid_multibyte", + Box::new(|| { + ( + Box::new(StringLenBytes { + val: "世界和平".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_min_bytes_valid", + Box::new(|| { + ( + Box::new(StringMinBytes { + val: "proto".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_bytes_valid_min", + Box::new(|| { + ( + Box::new(StringMinBytes { + val: "quux".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_bytes_valid_multibyte", + Box::new(|| { + ( + Box::new(StringMinBytes { + val: "你好".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_bytes_invalid", + Box::new(|| { + ( + Box::new(StringMinBytes { + val: "".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_max_bytes_valid", + Box::new(|| { + ( + Box::new(StringMaxBytes { + val: "foo".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_max_bytes_valid_max", + Box::new(|| { + ( + Box::new(StringMaxBytes { + val: "12345678".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_max_bytes_invalid", + Box::new(|| { + ( + Box::new(StringMaxBytes { + val: "123456789".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_max_bytes_invalid_multibyte", + Box::new(|| { + ( + Box::new(StringMaxBytes { + val: "你好你好你好".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_min_max_bytes_valid", + Box::new(|| { + ( + Box::new(StringMinMaxBytes { + val: "protoc".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_max_bytes_valid_min", + Box::new(|| { + ( + Box::new(StringMinMaxBytes { + val: "quux".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_max_bytes_valid_max", + Box::new(|| { + ( + Box::new(StringMinMaxBytes { + val: "fizzbuzz".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_max_bytes_valid_multibyte", + Box::new(|| { + ( + Box::new(StringMinMaxBytes { + val: "你好".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_min_max_bytes_invalid_below", + Box::new(|| { + ( + Box::new(StringMinMaxBytes { + val: "foo".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_min_max_bytes_invalid_above", + Box::new(|| { + ( + Box::new(StringMinMaxBytes { + val: "你好你好你".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_equal_min_max_bytes_valid", + Box::new(|| { + ( + Box::new(StringEqualMinMaxBytes { + val: "protoc".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_equal_min_max_bytes_invalid", + Box::new(|| { + ( + Box::new(StringEqualMinMaxBytes { + val: "foo".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_pattern_valid", + Box::new(|| { + ( + Box::new(StringPattern { + val: "Foo123".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_pattern_invalid", + Box::new(|| { + ( + Box::new(StringPattern { + val: "!@#$%^&*()".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_pattern_invalid_empty", + Box::new(|| { + ( + Box::new(StringPattern { + val: "".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_pattern_invalid_null", + Box::new(|| { + ( + Box::new(StringPattern { + val: "a\x0000".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_pattern_escapes_valid", + Box::new(|| { + ( + Box::new(StringPatternEscapes { + val: "* \\ x".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_pattern_escapes_invalid", + Box::new(|| { + ( + Box::new(StringPatternEscapes { + val: "invalid".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_pattern_escapes_invalid_empty", + Box::new(|| { + ( + Box::new(StringPatternEscapes { + val: "".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_prefix_valid", + Box::new(|| { + ( + Box::new(StringPrefix { + val: "foobar".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_prefix_valid_only", + Box::new(|| { + ( + Box::new(StringPrefix { + val: "foo".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_prefix_invalid", + Box::new(|| { + ( + Box::new(StringPrefix { + val: "bar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_prefix_invalid_case_sensitive", + Box::new(|| { + ( + Box::new(StringPrefix { + val: "Foobar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_contains_valid", + Box::new(|| { + ( + Box::new(StringContains { + val: "candy bars".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_contains_valid_only", + Box::new(|| { + ( + Box::new(StringContains { + val: "bar".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_contains_invalid", + Box::new(|| { + ( + Box::new(StringContains { + val: "candy bazs".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_contains_invalid_case_sensitive", + Box::new(|| { + ( + Box::new(StringContains { + val: "Candy Bars".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_not_contains_valid", + Box::new(|| { + ( + Box::new(StringNotContains { + val: "candy bazs".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_not_contains_valid_case_sensitive", + Box::new(|| { + ( + Box::new(StringNotContains { + val: "Candy Bars".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_not_contains_invalid", + Box::new(|| { + ( + Box::new(StringNotContains { + val: "candy bars".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_not_contains_invalid_equal", + Box::new(|| { + ( + Box::new(StringNotContains { + val: "bar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_suffix_valid", + Box::new(|| { + ( + Box::new(StringSuffix { + val: "foobaz".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_suffix_valid_only", + Box::new(|| { + ( + Box::new(StringSuffix { + val: "baz".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_suffix_invalid", + Box::new(|| { + ( + Box::new(StringSuffix { + val: "foobar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_suffix_invalid_case_sensitive", + Box::new(|| { + ( + Box::new(StringSuffix { + val: "FooBaz".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_email_valid", + Box::new(|| { + ( + Box::new(StringEmail { + val: "foo@bar.com".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_email_valid_name", + Box::new(|| { + ( + Box::new(StringEmail { + val: "John Smith ".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_email_invalid", + Box::new(|| { + ( + Box::new(StringEmail { + val: "foobar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_email_invalid_local_segment_too_long", + Box::new(|| { + (Box::new(StringEmail{val: "x0123456789012345678901234567890123456789012345678901234567890123456789@example.com".to_string()}) as Box, 1) + }) as Factory, + ), + ( + "string_email_invalid_hostname_too_long", + Box::new(|| { + (Box::new(StringEmail{val: "foo@x0123456789012345678901234567890123456789012345678901234567890123456789.com".to_string()}) as Box, 1) + }) as Factory, + ), + ( + "string_email_invalid_bad_hostname", + Box::new(|| { + ( + Box::new(StringEmail { + val: "foo@-bar.com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_email_empty", + Box::new(|| { + ( + Box::new(StringEmail { + val: "".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_address_valid_hostname", + Box::new(|| { + ( + Box::new(StringAddress { + val: "example.com".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_address_valid_hostname_uppercase", + Box::new(|| { + ( + Box::new(StringAddress { + val: "ASD.example.com".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_address_valid_hostname_hyphens", + Box::new(|| { + ( + Box::new(StringAddress { + val: "foo-bar.com".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_address_valid_hostname_trailing_dot", + Box::new(|| { + ( + Box::new(StringAddress { + val: "example.com.".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_address_invalid_hostname", + Box::new(|| { + ( + Box::new(StringAddress { + val: "!@#$%^&".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_address_invalid_hostname_underscore", + Box::new(|| { + ( + Box::new(StringAddress { + val: "foo_bar.com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_address_invalid_hostname_too_long", + Box::new(|| { + (Box::new(StringAddress{val: "x0123456789012345678901234567890123456789012345678901234567890123456789.com".to_string()}) as Box, 1) + }) as Factory, + ), + ( + "string_address_invalid_hostname_trailing_hyphens", + Box::new(|| { + ( + Box::new(StringAddress { + val: "foo-bar-.com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_address_invalid_hostname_leading_hyphens", + Box::new(|| { + ( + Box::new(StringAddress { + val: "foo-bar.-com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_address_invalid_hostname_empty", + Box::new(|| { + ( + Box::new(StringAddress { + val: "asd..asd.com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_address_invalid_hostname_idns", + Box::new(|| { + ( + Box::new(StringAddress { + val: "你好.com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_address_valid_ip_v4", + Box::new(|| { + ( + Box::new(StringAddress { + val: "192.168.0.1".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_address_valid_ip_v6", + Box::new(|| { + ( + Box::new(StringAddress { + val: "3e::99".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_address_invalid_ip", + Box::new(|| { + ( + Box::new(StringAddress { + val: "ff::fff::0b".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_hostname_valid", + Box::new(|| { + ( + Box::new(StringHostname { + val: "example.com".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_hostname_valid_uppercase", + Box::new(|| { + ( + Box::new(StringHostname { + val: "ASD.example.com".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_hostname_valid_hyphens", + Box::new(|| { + ( + Box::new(StringHostname { + val: "foo-bar.com".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_hostname_valid_trailing_dot", + Box::new(|| { + ( + Box::new(StringHostname { + val: "example.com.".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_hostname_invalid", + Box::new(|| { + ( + Box::new(StringHostname { + val: "!@#$%^&".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_hostname_invalid_underscore", + Box::new(|| { + ( + Box::new(StringHostname { + val: "foo_bar.com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_hostname_invalid_too_long", + Box::new(|| { + (Box::new(StringHostname{val: "x0123456789012345678901234567890123456789012345678901234567890123456789.com".to_string()}) as Box, 1) + }) as Factory, + ), + ( + "string_hostname_invalid_trailing_hyphens", + Box::new(|| { + ( + Box::new(StringHostname { + val: "foo-bar-.com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_hostname_invalid_leading_hyphens", + Box::new(|| { + ( + Box::new(StringHostname { + val: "foo-bar.-com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_hostname_invalid_empty", + Box::new(|| { + ( + Box::new(StringHostname { + val: "asd..asd.com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_hostname_invalid_idns", + Box::new(|| { + ( + Box::new(StringHostname { + val: "你好.com".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_ip_valid_v4", + Box::new(|| { + ( + Box::new(StringIp { + val: "192.168.0.1".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_ip_valid_v6", + Box::new(|| { + ( + Box::new(StringIp { + val: "3e::99".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_ip_invalid", + Box::new(|| { + ( + Box::new(StringIp { + val: "foobar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_ipv4_valid", + Box::new(|| { + ( + Box::new(StringIPv4 { + val: "192.168.0.1".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_ipv4_invalid", + Box::new(|| { + ( + Box::new(StringIPv4 { + val: "foobar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_ipv4_invalid_erroneous", + Box::new(|| { + ( + Box::new(StringIPv4 { + val: "256.0.0.0".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_ipv4_invalid_v6", + Box::new(|| { + ( + Box::new(StringIPv4 { + val: "3e::99".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_ipv6_valid", + Box::new(|| { + ( + Box::new(StringIPv6 { + val: "2001:0db8:85a3:0000:0000:8a2e:0370:7334".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_ipv6_valid_collapsed", + Box::new(|| { + ( + Box::new(StringIPv6 { + val: "2001:db8:85a3::8a2e:370:7334".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_ipv6_invalid", + Box::new(|| { + ( + Box::new(StringIPv6 { + val: "foobar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_ipv6_invalid_v4", + Box::new(|| { + ( + Box::new(StringIPv6 { + val: "192.168.0.1".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_ipv6_invalid_erroneous", + Box::new(|| { + ( + Box::new(StringIPv6 { + val: "ff::fff::0b".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_uri_valid_2", + Box::new(|| { + ( + Box::new(StringUri { + val: "http://example.com/foo/bar?baz=quux".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uri_invalid_2", + Box::new(|| { + ( + Box::new(StringUri { + val: "!@#$%^&*%$#".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_uri_invalid_relative", + Box::new(|| { + ( + Box::new(StringUri { + val: "/foo/bar?baz=quux".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_uri_valid_3", + Box::new(|| { + ( + Box::new(StringUriRef { + val: "http://example.com/foo/bar?baz=quux".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uri_valid_relative", + Box::new(|| { + ( + Box::new(StringUriRef { + val: "/foo/bar?baz=quux".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uri_invalid_3", + Box::new(|| { + ( + Box::new(StringUriRef { + val: "!@#$%^&*%$#".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_uuid_valid_nil", + Box::new(|| { + ( + Box::new(StringUuid { + val: "00000000-0000-0000-0000-000000000000".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_valid_v1", + Box::new(|| { + ( + Box::new(StringUuid { + val: "b45c0c80-8880-11e9-a5b1-000000000000".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_valid_v1_case_insensitive", + Box::new(|| { + ( + Box::new(StringUuid { + val: "B45C0C80-8880-11E9-A5B1-000000000000".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_valid_v2", + Box::new(|| { + ( + Box::new(StringUuid { + val: "b45c0c80-8880-21e9-a5b1-000000000000".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_valid_v2_case_insensitive", + Box::new(|| { + ( + Box::new(StringUuid { + val: "B45C0C80-8880-21E9-A5B1-000000000000".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_valid_v3", + Box::new(|| { + ( + Box::new(StringUuid { + val: "a3bb189e-8bf9-3888-9912-ace4e6543002".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_valid_v3_case_insensitive", + Box::new(|| { + ( + Box::new(StringUuid { + val: "A3BB189E-8BF9-3888-9912-ACE4E6543002".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_valid_v4", + Box::new(|| { + ( + Box::new(StringUuid { + val: "8b208305-00e8-4460-a440-5e0dcd83bb0a".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_valid_v4_case_insensitive", + Box::new(|| { + ( + Box::new(StringUuid { + val: "8B208305-00E8-4460-A440-5E0DCD83BB0A".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_valid_v5", + Box::new(|| { + ( + Box::new(StringUuid { + val: "a6edc906-2f9f-5fb2-a373-efac406f0ef2".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_valid_v5_case_insensitive", + Box::new(|| { + ( + Box::new(StringUuid { + val: "A6EDC906-2F9F-5FB2-A373-EFAC406F0EF2".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_uuid_invalid", + Box::new(|| { + ( + Box::new(StringUuid { + val: "foobar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_uuid_invalid_bad_uuid", + Box::new(|| { + ( + Box::new(StringUuid { + val: "ffffffff-ffff-ffff-ffff-fffffffffffff".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_uuid_valid_ignore_empty", + Box::new(|| { + ( + Box::new(StringUuidIgnore { + val: "".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_name_valid", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: "clustername".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_name_valid_2", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: ":path".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_name_valid_nums", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: "cluster-123".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_name_valid_special_token", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: "!+#&.%".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_name_valid_period", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: "CLUSTER.NAME".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_name_invalid", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: ":".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_http_header_name_invalid_2", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: ":path:".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_http_header_name_invalid_space", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: "cluster name".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_http_header_name_invalid_return", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: "example\r".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_http_header_name_invalid_tab", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: "example\t".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_http_header_name_invalid_slash", + Box::new(|| { + ( + Box::new(StringHttpHeaderName { + val: "/test/long/url".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_http_header_value_valid", + Box::new(|| { + ( + Box::new(StringHttpHeaderValue { + val: "cluster.name.123".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_value_valid_uppercase", + Box::new(|| { + ( + Box::new(StringHttpHeaderValue { + val: "/TEST/LONG/URL".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_value_valid_spaces", + Box::new(|| { + ( + Box::new(StringHttpHeaderValue { + val: "cluster name".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_value_valid_tab", + Box::new(|| { + ( + Box::new(StringHttpHeaderValue { + val: "example\t".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_value_valid_special_token", + Box::new(|| { + ( + Box::new(StringHttpHeaderValue { + val: "!#%&./+".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_http_header_value_invalid_nul", + Box::new(|| { + ( + Box::new(StringHttpHeaderValue { + val: "foo\u{0000}bar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_http_header_value_invalid_del", + Box::new(|| { + ( + Box::new(StringHttpHeaderValue { + val: "\u{007f}".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_http_header_value_invalid", + Box::new(|| { + ( + Box::new(StringHttpHeaderValue { + val: "example\r".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_non_strict_valid_header_valid", + Box::new(|| { + ( + Box::new(StringValidHeader { + val: "cluster.name.123".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_non_strict_valid_header_valid_uppercase", + Box::new(|| { + ( + Box::new(StringValidHeader { + val: "/TEST/LONG/URL".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_non_strict_valid_header_valid_spaces", + Box::new(|| { + ( + Box::new(StringValidHeader { + val: "cluster name".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_non_strict_valid_header_valid_tab", + Box::new(|| { + ( + Box::new(StringValidHeader { + val: "example\t".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_non_strict_valid_header_valid_del", + Box::new(|| { + ( + Box::new(StringValidHeader { + val: "\u{007f}".to_string(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "string_non_strict_valid_header_invalid_nul", + Box::new(|| { + ( + Box::new(StringValidHeader { + val: "foo\u{0000}bar".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_non_strict_valid_header_invalid_cr", + Box::new(|| { + ( + Box::new(StringValidHeader { + val: "example\r".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "string_non_strict_valid_header_invalid_nl", + Box::new(|| { + ( + Box::new(StringValidHeader { + val: "exa\u{000A}mple".to_string(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_none_valid", + Box::new(|| { + ( + Box::new(BytesNone { + val: b"quux".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_const_valid", + Box::new(|| { + ( + Box::new(BytesConst { + val: b"foo".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_const_invalid", + Box::new(|| { + ( + Box::new(BytesConst { + val: b"bar".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_in_valid", + Box::new(|| { + ( + Box::new(BytesIn { + val: b"bar".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_in_invalid", + Box::new(|| { + ( + Box::new(BytesIn { + val: b"quux".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_not_in_valid", + Box::new(|| { + ( + Box::new(BytesNotIn { + val: b"quux".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_not_in_invalid", + Box::new(|| { + ( + Box::new(BytesNotIn { + val: b"fizz".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_len_valid", + Box::new(|| { + ( + Box::new(BytesLen { + val: b"baz".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_len_invalid_lt", + Box::new(|| { + ( + Box::new(BytesLen { + val: b"go".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_len_invalid_gt", + Box::new(|| { + ( + Box::new(BytesLen { + val: b"fizz".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_min_len_valid", + Box::new(|| { + ( + Box::new(BytesMinLen { + val: b"fizz".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_min_len_valid_min", + Box::new(|| { + ( + Box::new(BytesMinLen { + val: b"baz".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_min_len_invalid", + Box::new(|| { + ( + Box::new(BytesMinLen { + val: b"go".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_max_len_valid", + Box::new(|| { + ( + Box::new(BytesMaxLen { + val: b"foo".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_max_len_valid_max", + Box::new(|| { + ( + Box::new(BytesMaxLen { + val: b"proto".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_max_len_invalid", + Box::new(|| { + ( + Box::new(BytesMaxLen { + val: b"1234567890".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_min_max_len_valid", + Box::new(|| { + ( + Box::new(BytesMinMaxLen { + val: b"quux".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_min_max_len_valid_min", + Box::new(|| { + ( + Box::new(BytesMinMaxLen { + val: b"foo".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_min_max_len_valid_max", + Box::new(|| { + ( + Box::new(BytesMinMaxLen { + val: b"proto".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_min_max_len_invalid_below", + Box::new(|| { + ( + Box::new(BytesMinMaxLen { + val: b"go".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_min_max_len_invalid_above", + Box::new(|| { + ( + Box::new(BytesMinMaxLen { + val: b"validate".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_equal_min_max_len_valid", + Box::new(|| { + ( + Box::new(BytesEqualMinMaxLen { + val: b"proto".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_equal_min_max_len_invalid", + Box::new(|| { + ( + Box::new(BytesEqualMinMaxLen { + val: b"validate".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_pattern_valid", + Box::new(|| { + ( + Box::new(BytesPattern { + val: b"Foo123".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + // b"你好你好" + ( + "bytes_pattern_invalid", + Box::new(|| { + ( + Box::new(BytesPattern { + val: b"\xE4\xBD\xA0\xE5\xA5\xBD\xE4\xBD\xA0\xE5\xA5\xBD".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_pattern_invalid_empty", + Box::new(|| { + ( + Box::new(BytesPattern { val: b"".to_vec() }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_prefix_valid", + Box::new(|| { + ( + Box::new(BytesPrefix { + val: vec![0x99, 0x9f, 0x08], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_prefix_valid_only", + Box::new(|| { + ( + Box::new(BytesPrefix { val: vec![0x99] }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_prefix_invalid", + Box::new(|| { + ( + Box::new(BytesPrefix { + val: b"bar".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_contains_valid", + Box::new(|| { + ( + Box::new(BytesContains { + val: b"candy bars".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_contains_valid_only", + Box::new(|| { + ( + Box::new(BytesContains { + val: b"bar".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_contains_invalid", + Box::new(|| { + ( + Box::new(BytesContains { + val: b"candy bazs".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_suffix_valid", + Box::new(|| { + ( + Box::new(BytesSuffix { + val: vec![0x62, 0x75, 0x7A, 0x7A], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_suffix_valid_only", + Box::new(|| { + ( + Box::new(BytesSuffix { + val: b"\x62\x75\x7A\x7A".to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_suffix_invalid", + Box::new(|| { + ( + Box::new(BytesSuffix { + val: b"foobar".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_suffix_invalid_case_sensitive", + Box::new(|| { + ( + Box::new(BytesSuffix { + val: b"FooBaz".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_ip_valid_v4", + Box::new(|| { + ( + Box::new(BytesIp { + val: vec![0xC0, 0xA8, 0x00, 0x01], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_ip_valid_v6", + Box::new(|| { + ( + Box::new(BytesIp { + val: b"\x20\x01\x0D\xB8\x85\xA3\x00\x00\x00\x00\x8A\x2E\x03\x70\x73\x34" + .to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_ip_invalid", + Box::new(|| { + ( + Box::new(BytesIp { + val: b"foobar".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_ipv4_valid", + Box::new(|| { + ( + Box::new(BytesIPv4 { + val: vec![0xC0, 0xA8, 0x00, 0x01], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_ipv4_invalid", + Box::new(|| { + ( + Box::new(BytesIPv4 { + val: b"foobar".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_ipv4_invalid_v6", + Box::new(|| { + ( + Box::new(BytesIPv4 { + val: b"\x20\x01\x0D\xB8\x85\xA3\x00\x00\x00\x00\x8A\x2E\x03\x70\x73\x34" + .to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_ipv6_valid", + Box::new(|| { + ( + Box::new(BytesIPv6 { + val: b"\x20\x01\x0D\xB8\x85\xA3\x00\x00\x00\x00\x8A\x2E\x03\x70\x73\x34" + .to_vec(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "bytes_ipv6_invalid", + Box::new(|| { + ( + Box::new(BytesIPv6 { + val: b"fooar".to_vec(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_ipv6_invalid_v4", + Box::new(|| { + ( + Box::new(BytesIPv6 { + val: vec![0xC0, 0xA8, 0x00, 0x01], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "bytes_ipv6_valid_ignore_empty", + Box::new(|| { + ( + Box::new(BytesIPv6Ignore::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_none_valid", + Box::new(|| { + ( + Box::new(EnumNone { + val: TestEnum::One.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_const_valid", + Box::new(|| { + ( + Box::new(EnumConst { + val: TestEnum::Two.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_const_invalid", + Box::new(|| { + ( + Box::new(EnumConst { + val: TestEnum::One.into(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_alias_const_valid", + Box::new(|| { + ( + Box::new(EnumAliasConst { + val: TestEnumAlias::C.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_alias_const_valid_alias", + Box::new(|| { + ( + Box::new(EnumAliasConst { + val: TestEnumAlias::C.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_alias_const_invalid", + Box::new(|| { + ( + Box::new(EnumAliasConst { + val: TestEnumAlias::A.into(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_defined_only_valid", + Box::new(|| (Box::new(EnumDefined { val: 0 }) as Box, 0)) as Factory, + ), + ( + "enum_defined_only_invalid", + Box::new(|| { + ( + Box::new(EnumDefined { val: i32::MAX }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_alias_defined_only_valid", + Box::new(|| { + ( + Box::new(EnumAliasDefined { val: 1 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_alias_defined_only_invalid", + Box::new(|| { + ( + Box::new(EnumAliasDefined { val: i32::MAX }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_in_valid", + Box::new(|| { + ( + Box::new(EnumIn { + val: TestEnum::Two.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_in_invalid", + Box::new(|| { + ( + Box::new(EnumIn { + val: TestEnum::One.into(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_alias_in_valid", + Box::new(|| { + ( + Box::new(EnumAliasIn { + val: TestEnumAlias::A.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_alias_in_valid_alias", + Box::new(|| { + ( + Box::new(EnumAliasIn { + val: TestEnumAlias::A.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_alias_in_invalid", + Box::new(|| { + ( + Box::new(EnumAliasIn { + val: TestEnumAlias::B.into(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_not_in_valid", + Box::new(|| { + ( + Box::new(EnumNotIn { + val: TestEnum::Zero.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_not_in_valid_undefined", + Box::new(|| { + ( + Box::new(EnumNotIn { val: i32::MAX }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_not_in_invalid", + Box::new(|| { + ( + Box::new(EnumNotIn { + val: TestEnum::One.into(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_alias_not_in_valid", + Box::new(|| { + ( + Box::new(EnumAliasNotIn { + val: TestEnumAlias::A.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_alias_not_in_invalid", + Box::new(|| { + ( + Box::new(EnumAliasNotIn { + val: TestEnumAlias::B.into(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_alias_not_in_invalid_alias", + Box::new(|| { + ( + Box::new(EnumAliasNotIn { + val: TestEnumAlias::B.into(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_external_defined_only_valid", + Box::new(|| { + ( + Box::new(EnumExternal { + val: other_package::embed::Enumerated::Value.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_external_defined_only_invalid", + Box::new(|| { + ( + Box::new(EnumExternal { val: i32::MAX }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_external_in_valid", + Box::new(|| { + ( + Box::new(EnumExternal3 { + foo: other_package::embed::FooNumber::Zero.into(), + bar: 0, + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_external_in_invalid", + Box::new(|| { + ( + Box::new(EnumExternal3 { + foo: other_package::embed::FooNumber::One.into(), + bar: 0, + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_external_not_in_valid", + Box::new(|| { + ( + Box::new(EnumExternal3 { + bar: yet_another_package::embed::BarNumber::Zero.into(), + foo: 0, + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_external_not_in_invalid", + Box::new(|| { + ( + Box::new(EnumExternal3 { + bar: yet_another_package::embed::BarNumber::One.into(), + foo: 0, + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_external_const_valid", + Box::new(|| { + ( + Box::new(EnumExternal4 { + sort_direction: sort::Direction::Asc.into(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_external_const_invalid", + Box::new(|| { + ( + Box::new(EnumExternal4 { + sort_direction: sort::Direction::Desc.into(), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_repeated_defined_only_valid", + Box::new(|| { + ( + Box::new(RepeatedEnumDefined { + val: vec![TestEnum::One.into(), TestEnum::Two.into()], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_repeated_defined_only_invalid", + Box::new(|| { + ( + Box::new(RepeatedEnumDefined { + val: vec![TestEnum::One.into(), i32::MAX], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_repeated_external_defined_only_valid", + Box::new(|| { + ( + Box::new(RepeatedExternalEnumDefined { + val: vec![other_package::embed::Enumerated::Value.into()], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_repeated_external_defined_only_invalid", + Box::new(|| { + ( + Box::new(RepeatedExternalEnumDefined { + val: vec![i32::MAX], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_repeated_another_external_defined_only_valid", + Box::new(|| { + ( + Box::new(RepeatedYetAnotherExternalEnumDefined { + val: vec![yet_another_package::embed::Enumerated::Value.into()], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_repeated_external_in_valid", + Box::new(|| { + ( + Box::new(RepeatedEnumExternal { + foo: vec![ + other_package::embed::FooNumber::Zero.into(), + other_package::embed::FooNumber::Two.into(), + ], + ..RepeatedEnumExternal::default() + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_repeated_external_in_invalid", + Box::new(|| { + ( + Box::new(RepeatedEnumExternal { + foo: vec![other_package::embed::FooNumber::One.into()], + ..RepeatedEnumExternal::default() + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_repeated_external_not_in_valid", + Box::new(|| { + ( + Box::new(RepeatedEnumExternal { + bar: vec![ + yet_another_package::embed::BarNumber::Zero.into(), + yet_another_package::embed::BarNumber::Two.into(), + ], + ..RepeatedEnumExternal::default() + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_repeated_external_not_in_invalid", + Box::new(|| { + ( + Box::new(RepeatedEnumExternal { + bar: vec![yet_another_package::embed::BarNumber::One.into()], + ..RepeatedEnumExternal::default() + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_map_defined_only_valid", + Box::new(|| { + ( + Box::new(MapEnumDefined { + val: HashMap::from([("foo".to_string(), TestEnum::Two.into())]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_map_defined_only_invalid", + Box::new(|| { + ( + Box::new(MapEnumDefined { + val: HashMap::from([("foo".to_string(), i32::MAX)]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "enum_map_external_defined_only_valid", + Box::new(|| { + ( + Box::new(MapExternalEnumDefined { + val: HashMap::from([( + "foo".to_string(), + other_package::embed::Enumerated::Value.into(), + )]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "enum_map_external_defined_only_invalid", + Box::new(|| { + ( + Box::new(MapExternalEnumDefined { + val: HashMap::from([("foo".to_string(), i32::MAX)]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "message_none_valid", + Box::new(|| { + ( + Box::new(MessageNone { + val: Some(message_none::NoneMsg::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_none_valid_unset", + Box::new(|| (Box::new(MessageNone::default()) as Box, 0)) as Factory, + ), + ( + "message_disabled_valid", + Box::new(|| { + ( + Box::new(MessageDisabled { val: 456 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_disabled_valid_invalid_field", + Box::new(|| { + ( + Box::new(MessageDisabled { val: 0 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_ignored_valid", + Box::new(|| { + ( + Box::new(MessageIgnored { val: 456 }) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_ignored_valid_invalid_field", + Box::new(|| (Box::new(MessageIgnored { val: 0 }) as Box, 0)) as Factory, + ), + ( + "message_field_valid", + Box::new(|| { + ( + Box::new(cases::Message { + val: Some(TestMsg { + r#const: "foo".to_string(), + ..TestMsg::default() + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_field_valid_unset", + Box::new(|| (Box::new(cases::Message::default()) as Box, 0)) as Factory, + ), + ( + "message_field_invalid", + Box::new(|| { + ( + Box::new(cases::Message { + val: Some(TestMsg::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "message_field_invalid_transitive", + Box::new(|| { + ( + Box::new(cases::Message { + val: Some(TestMsg { + r#const: "foo".to_string(), + nested: Some(Box::new(TestMsg::default())), + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "message_skip_valid", + Box::new(|| { + ( + Box::new(MessageSkip { + val: Some(TestMsg::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_required_valid", + Box::new(|| { + ( + Box::new(MessageRequired { + val: Some(TestMsg { + r#const: "foo".to_string(), + ..TestMsg::default() + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_required_valid_oneof", + Box::new(|| { + ( + Box::new(MessageRequiredOneof { + one: Some(One::Val(TestMsg { + r#const: "foo".to_string(), + ..TestMsg::default() + })), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_required_invalid", + Box::new(|| { + ( + Box::new(MessageRequired::default()) as Box, + 1, + ) + }) as Factory, + ), + ( + "message_required_invalid_oneof", + Box::new(|| { + ( + Box::new(MessageRequiredOneof::default()) as Box, + 1, + ) + }) as Factory, + ), + ( + "message_cross_package_embed_none_valid", + Box::new(|| { + ( + Box::new(MessageCrossPackage { + val: Some(other_package::Embed { val: 1 }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_cross_package_embed_none_valid_nil", + Box::new(|| { + ( + Box::new(MessageCrossPackage::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_cross_package_embed_none_valid_empty", + Box::new(|| { + ( + Box::new(MessageCrossPackage { + val: Some(other_package::Embed::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "message_cross_package_embed_none_invalid", + Box::new(|| { + ( + Box::new(MessageCrossPackage { + val: Some(other_package::Embed { val: -1 }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "message_required_valid_2", + Box::new(|| { + ( + Box::new(MessageRequiredButOptional { + val: Some(TestMsg { + r#const: "foo".to_string(), + ..TestMsg::default() + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "message_required_valid_unset", + Box::new(|| { + ( + Box::new(MessageRequiredButOptional::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_none_valid", + Box::new(|| { + ( + Box::new(RepeatedNone { val: vec![1, 2, 3] }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_embed_none_valid", + Box::new(|| { + ( + Box::new(RepeatedEmbedNone { + val: vec![cases::Embed { val: 1 }], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_embed_none_valid_nil", + Box::new(|| { + ( + Box::new(RepeatedEmbedNone::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_embed_none_valid_empty", + Box::new(|| { + ( + Box::new(RepeatedEmbedNone::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_embed_none_invalid", + Box::new(|| { + ( + Box::new(RepeatedEmbedNone { + val: vec![cases::Embed { val: -1 }], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_cross_package_embed_none_valid", + Box::new(|| { + ( + Box::new(RepeatedEmbedCrossPackageNone { + val: vec![other_package::Embed { val: 1 }], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_cross_package_embed_none_valid_nil", + Box::new(|| { + ( + Box::new(RepeatedEmbedCrossPackageNone::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_cross_package_embed_none_valid_empty", + Box::new(|| { + ( + Box::new(RepeatedEmbedCrossPackageNone::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_cross_package_embed_none_invalid", + Box::new(|| { + ( + Box::new(RepeatedEmbedCrossPackageNone { + val: vec![other_package::Embed { val: -1 }], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_min_valid", + Box::new(|| { + ( + Box::new(RepeatedMin { + val: vec![ + cases::Embed { val: 1 }, + cases::Embed { val: 2 }, + cases::Embed { val: 3 }, + ], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_min_valid_equal", + Box::new(|| { + ( + Box::new(RepeatedMin { + val: vec![cases::Embed { val: 1 }, cases::Embed { val: 2 }], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_min_invalid", + Box::new(|| { + ( + Box::new(RepeatedMin { + val: vec![cases::Embed { val: 1 }], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_min_invalid_element", + Box::new(|| { + ( + Box::new(RepeatedMin { + val: vec![cases::Embed { val: 1 }, cases::Embed { val: -1 }], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_max_valid", + Box::new(|| { + ( + Box::new(RepeatedMax { val: vec![1., 2.] }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_max_valid_equal", + Box::new(|| { + ( + Box::new(RepeatedMax { + val: vec![1., 2., 3.], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_max_invalid", + Box::new(|| { + ( + Box::new(RepeatedMax { + val: vec![1., 2., 3., 4.], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_min_max_valid", + Box::new(|| { + ( + Box::new(RepeatedMinMax { val: vec![1, 2, 3] }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_min_max_valid_min", + Box::new(|| { + ( + Box::new(RepeatedMinMax { val: vec![1, 2] }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_min_max_valid_max", + Box::new(|| { + ( + Box::new(RepeatedMinMax { + val: vec![1, 2, 3, 4], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_min_max_invalid_below", + Box::new(|| (Box::new(RepeatedMinMax::default()) as Box, 1)) as Factory, + ), + ( + "repeated_min_max_invalid_above", + Box::new(|| { + ( + Box::new(RepeatedMinMax { + val: vec![1, 2, 3, 4, 5], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_exact_valid", + Box::new(|| { + ( + Box::new(RepeatedExact { val: vec![1, 2, 3] }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_exact_invalid_below", + Box::new(|| { + ( + Box::new(RepeatedExact { val: vec![1, 2] }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_exact_invalid_above", + Box::new(|| { + ( + Box::new(RepeatedExact { + val: vec![1, 2, 3, 4], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_unique_valid", + Box::new(|| { + ( + Box::new(RepeatedUnique { + val: vec!["foo".to_string(), "bar".to_string(), "baz".to_string()], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_unique_valid_empty", + Box::new(|| (Box::new(RepeatedUnique::default()) as Box, 0)) as Factory, + ), + ( + "repeated_unique_valid_case_sensitivity", + Box::new(|| { + ( + Box::new(RepeatedUnique { + val: vec!["foo".to_string(), "Foo".to_string()], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_unique_invalid", + Box::new(|| { + ( + Box::new(RepeatedUnique { + val: vec![ + "foo".to_string(), + "bar".to_string(), + "foo".to_string(), + "baz".to_string(), + ], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_valid", + Box::new(|| { + ( + Box::new(RepeatedItemRule { + val: vec![1., 2., 3.], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_items_valid_empty", + Box::new(|| { + ( + Box::new(RepeatedItemRule::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_items_valid_pattern", + Box::new(|| { + ( + Box::new(RepeatedItemPattern { + val: vec!["Alpha".to_string(), "Beta123".to_string()], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_items_invalid", + Box::new(|| { + ( + Box::new(RepeatedItemRule { + val: vec![1., -2., 3.], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_invalid_pattern", + Box::new(|| { + ( + Box::new(RepeatedItemPattern { + val: vec!["Alpha".to_string(), "!@#$%^&*()".to_string()], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_invalid_in", + Box::new(|| { + ( + Box::new(RepeatedItemIn { + val: vec!["baz".to_string()], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_valid_in", + Box::new(|| { + ( + Box::new(RepeatedItemIn { + val: vec!["foo".to_string()], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_items_invalid_not_in", + Box::new(|| { + ( + Box::new(RepeatedItemNotIn { + val: vec!["foo".to_string()], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_valid_not_in", + Box::new(|| { + ( + Box::new(RepeatedItemNotIn { + val: vec!["baz".to_string()], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_items_invalid_enum_in", + Box::new(|| { + ( + Box::new(RepeatedEnumIn { val: vec![1] }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_valid_enum_in", + Box::new(|| { + ( + Box::new(RepeatedEnumIn { val: vec![0] }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_items_invalid_enum_not_in", + Box::new(|| { + ( + Box::new(RepeatedEnumNotIn { val: vec![0] }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_valid_enum_not_in", + Box::new(|| { + ( + Box::new(RepeatedEnumNotIn { val: vec![1] }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_items_invalid_embedded_enum_in", + Box::new(|| { + ( + Box::new(RepeatedEmbeddedEnumIn { val: vec![1] }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_valid_embedded_enum_in", + Box::new(|| { + ( + Box::new(RepeatedEmbeddedEnumIn { val: vec![0] }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_items_invalid_embedded_enum_not_in", + Box::new(|| { + ( + Box::new(RepeatedEmbeddedEnumNotIn { val: vec![0] }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_valid_embedded_enum_not_in", + Box::new(|| { + ( + Box::new(RepeatedEmbeddedEnumNotIn { val: vec![1] }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_items_invalid_any_in", + Box::new(|| { + ( + Box::new(RepeatedAnyIn { + val: vec![Any { + type_url: "type.googleapis.com/google.protobuf.Timestamp".to_string(), + ..Any::default() + }], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_valid_any_in", + Box::new(|| { + ( + Box::new(RepeatedAnyIn { + val: vec![Any { + type_url: "type.googleapis.com/google.protobuf.Duration".to_string(), + ..Any::default() + }], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_items_invalid_any_not_in", + Box::new(|| { + ( + Box::new(RepeatedAnyNotIn { + val: vec![Any { + type_url: "type.googleapis.com/google.protobuf.Timestamp".to_string(), + ..Any::default() + }], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_items_valid_any_not_in", + Box::new(|| { + ( + Box::new(RepeatedAnyNotIn { + val: vec![Any { + type_url: "type.googleapis.com/google.protobuf.Duration".to_string(), + ..Any::default() + }], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_embed_skip_valid", + Box::new(|| { + ( + Box::new(RepeatedEmbedSkip { + val: vec![cases::Embed { val: 1 }], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_embed_skip_valid_invalid_element", + Box::new(|| { + ( + Box::new(RepeatedEmbedSkip { + val: vec![cases::Embed { val: -1 }], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_min_and_items_len_valid", + Box::new(|| { + ( + Box::new(RepeatedMinAndItemLen { + val: vec!["aaa".to_string(), "bbb".to_string()], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_min_and_items_len_invalid_min", + Box::new(|| { + ( + Box::new(RepeatedMinAndItemLen { + val: vec![String::default()], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_min_and_items_len_invalid_len", + Box::new(|| { + ( + Box::new(RepeatedMinAndItemLen { + val: vec!["x".to_string()], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_min_and_max_items_len_valid", + Box::new(|| { + ( + Box::new(RepeatedMinAndMaxItemLen { + val: vec!["aaa".to_string(), "bbb".to_string()], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_min_and_max_items_len_invalid_min_len", + Box::new(|| { + ( + Box::new(RepeatedMinAndMaxItemLen::default()) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_min_and_max_items_len_invalid_max_len", + Box::new(|| { + ( + Box::new(RepeatedMinAndMaxItemLen { + val: vec![ + "aaa".to_string(), + "bbb".to_string(), + "ccc".to_string(), + "ddd".to_string(), + ], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_duration_gte_valid", + Box::new(|| { + ( + Box::new(RepeatedDuration { + val: vec![Duration { + seconds: 3, + nanos: 0, + }], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_duration_gte_valid_empty", + Box::new(|| { + ( + Box::new(RepeatedDuration::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_duration_gte_valid_equal", + Box::new(|| { + ( + Box::new(RepeatedDuration { + val: vec![Duration { + nanos: 1000000, + seconds: 0, + }], + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "repeated_duration_gte_invalid", + Box::new(|| { + ( + Box::new(RepeatedDuration { + val: vec![Duration { + seconds: -1, + nanos: 0, + }], + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "repeated_exact_valid_ignore_empty", + Box::new(|| { + ( + Box::new(RepeatedExactIgnore::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_none_valid", + Box::new(|| { + ( + Box::new(MapNone { + val: HashMap::from([(123, true), (456, false)]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_min_pairs_valid", + Box::new(|| { + ( + Box::new(MapMin { + val: HashMap::from([(1, 2.), (3, 4.), (5, 6.)]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_min_pairs_valid_equal", + Box::new(|| { + ( + Box::new(MapMin { + val: HashMap::from([(1, 2.), (3, 4.)]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_min_pairs_invalid", + Box::new(|| { + ( + Box::new(MapMin { + val: HashMap::from([(1, 2.)]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_max_pairs_valid", + Box::new(|| { + ( + Box::new(MapMax { + val: HashMap::from([(1, 2.), (3, 4.)]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_max_pairs_valid_equal", + Box::new(|| { + ( + Box::new(MapMax { + val: HashMap::from([(1, 2.), (3, 4.), (5, 6.)]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_max_pairs_invalid", + Box::new(|| { + ( + Box::new(MapMax { + val: HashMap::from([(1, 2.), (3, 4.), (5, 6.), (7, 8.)]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_min_max_valid", + Box::new(|| { + ( + Box::new(MapMinMax { + val: HashMap::from([ + ("a".to_string(), true), + ("b".to_string(), false), + ("c".to_string(), true), + ]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_min_max_valid_min", + Box::new(|| { + ( + Box::new(MapMinMax { + val: HashMap::from([("a".to_string(), true), ("b".to_string(), false)]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_min_max_valid_max", + Box::new(|| { + ( + Box::new(MapMinMax { + val: HashMap::from([ + ("a".to_string(), true), + ("b".to_string(), false), + ("c".to_string(), true), + ("d".to_string(), false), + ]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_min_max_invalid_below", + Box::new(|| { + ( + Box::new(MapMinMax { + val: HashMap::from([]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_min_max_invalid_above", + Box::new(|| { + ( + Box::new(MapMinMax { + val: HashMap::from([ + ("a".to_string(), true), + ("b".to_string(), false), + ("c".to_string(), true), + ("d".to_string(), false), + ("e".to_string(), true), + ]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_exact_valid", + Box::new(|| { + ( + Box::new(MapExact { + val: HashMap::from([ + (1, "a".to_string()), + (2, "b".to_string()), + (3, "c".to_string()), + ]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_exact_invalid_below", + Box::new(|| { + ( + Box::new(MapExact { + val: HashMap::from([(1, "a".to_string()), (2, "b".to_string())]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_exact_invalid_above", + Box::new(|| { + ( + Box::new(MapExact { + val: HashMap::from([ + (1, "a".to_string()), + (2, "b".to_string()), + (3, "c".to_string()), + (4, "d".to_string()), + ]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_no_sparse_valid", + Box::new(|| { + ( + Box::new(MapNoSparse { + val: HashMap::from([ + (1, cases::map_no_sparse::Msg::default()), + (2, cases::map_no_sparse::Msg::default()), + ]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_no_sparse_valid_empty", + Box::new(|| { + ( + Box::new(MapNoSparse { + val: HashMap::from([]), + }) as Box, + 0, + ) + }) as Factory, + ), + // sparse maps are no longer supported, so this case is no longer possible + // "map_no_sparse_invalid", MapNoSparse{val: HashMap::from([(1, cases::map_no_sparse::Msg::default()), (2, None)])}, 1), + ( + "map_keys_valid", + Box::new(|| { + ( + Box::new(MapKeys { + val: HashMap::from([(-1, "a".to_string()), (-2, "b".to_string())]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_keys_valid_empty", + Box::new(|| { + ( + Box::new(MapKeys { + val: HashMap::default(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_keys_valid_pattern", + Box::new(|| { + ( + Box::new(MapKeysPattern { + val: HashMap::from([("A".to_string(), "a".to_string())]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_keys_valid_in", + Box::new(|| { + ( + Box::new(MapKeysIn { + val: HashMap::from([("foo".to_string(), "value".to_string())]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_keys_valid_not_in", + Box::new(|| { + ( + Box::new(MapKeysNotIn { + val: HashMap::from([("baz".to_string(), "value".to_string())]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_keys_invalid", + Box::new(|| { + ( + Box::new(MapKeys { + val: HashMap::from([(1, "a".to_string())]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_keys_invalid_pattern", + Box::new(|| { + ( + Box::new(MapKeysPattern { + val: HashMap::from([ + ("A".to_string(), "a".to_string()), + ("!@#$%^&*()".to_string(), "b".to_string()), + ]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_keys_invalid_in", + Box::new(|| { + ( + Box::new(MapKeysIn { + val: HashMap::from([("baz".to_string(), "value".to_string())]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_keys_invalid_not_in", + Box::new(|| { + ( + Box::new(MapKeysNotIn { + val: HashMap::from([("foo".to_string(), "value".to_string())]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_values_valid", + Box::new(|| { + ( + Box::new(MapValues { + val: HashMap::from([ + ("a".to_string(), "Alpha".to_string()), + ("b".to_string(), "Beta".to_string()), + ]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_values_valid_empty", + Box::new(|| { + ( + Box::new(MapValues { + val: HashMap::default(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_values_valid_pattern", + Box::new(|| { + ( + Box::new(MapValuesPattern { + val: HashMap::from([("a".to_string(), "A".to_string())]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_values_invalid", + Box::new(|| { + ( + Box::new(MapValues { + val: HashMap::from([ + ("a".to_string(), "A".to_string()), + ("b".to_string(), "B".to_string()), + ]), + }) as Box, + 2, + ) + }) as Factory, + ), + ( + "map_values_invalid_pattern", + Box::new(|| { + ( + Box::new(MapValuesPattern { + val: HashMap::from([ + ("a".to_string(), "A".to_string()), + ("b".to_string(), "!@#$%^&*()".to_string()), + ]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_recursive_valid", + Box::new(|| { + ( + Box::new(MapRecursive { + val: HashMap::from([( + 1, + cases::map_recursive::Msg { + val: "abc".to_string(), + }, + )]), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "map_recursive_invalid", + Box::new(|| { + ( + Box::new(MapRecursive { + val: HashMap::from([(1, cases::map_recursive::Msg::default())]), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "map_exact_valid_ignore_empty", + Box::new(|| (Box::new(MapExactIgnore::default()) as Box, 0)) as Factory, + ), + ( + "map_multiple_valid", + Box::new(|| { + ( + Box::new(MultipleMaps { + first: HashMap::from([(1, "a".to_string()), (2, "b".to_string())]), + second: HashMap::from([(-1, true), (-2, false)]), + third: HashMap::default(), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "oneof_none_valid", + Box::new(|| { + ( + Box::new(OneOfNone { + o: Some(one_of_none::O::X("foo".to_string())), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "oneof_none_valid_empty", + Box::new(|| (Box::new(OneOfNone::default()) as Box, 0)) as Factory, + ), + ( + "oneof_field_valid_x", + Box::new(|| { + ( + Box::new(OneOf { + o: Some(one_of::O::X("foobar".to_string())), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "oneof_field_valid_y", + Box::new(|| { + ( + Box::new(OneOf { + o: Some(one_of::O::Y(123)), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "oneof_field_valid_z", + Box::new(|| { + ( + Box::new(OneOf { + o: Some(one_of::O::Z(TestOneOfMsg { val: true })), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "oneof_field_valid_empty", + Box::new(|| (Box::new(OneOf::default()) as Box, 0)) as Factory, + ), + ( + "oneof_field_invalid_x", + Box::new(|| { + ( + Box::new(OneOf { + o: Some(one_of::O::X("fizzbuzz".to_string())), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "oneof_field_invalid_y", + Box::new(|| { + ( + Box::new(OneOf { + o: Some(one_of::O::Y(-1)), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "oneof_filed_invalid_z", + Box::new(|| { + ( + Box::new(OneOf { + o: Some(one_of::O::Z(TestOneOfMsg::default())), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "oneof_required_valid", + Box::new(|| { + ( + Box::new(OneOfRequired { + o: Some(one_of_required::O::X("".to_string())), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "oneof_require_invalid", + Box::new(|| (Box::new(OneOfRequired::default()) as Box, 1)) as Factory, + ), + ( + "oneof_ignore_empty_valid_x", + Box::new(|| { + ( + Box::new(OneOfIgnoreEmpty { + o: Some(one_of_ignore_empty::O::X("".to_string())), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "oneof_ignore_empty_valid_y", + Box::new(|| { + ( + Box::new(OneOfIgnoreEmpty { + o: Some(one_of_ignore_empty::O::Y(b"".to_vec())), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "oneof_ignore_empty_valid_z", + Box::new(|| { + ( + Box::new(OneOfIgnoreEmpty { + o: Some(one_of_ignore_empty::O::Z(0)), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_none_valid", + Box::new(|| { + ( + Box::new(WrapperNone { val: Some(123) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_none_valid_empty", + Box::new(|| (Box::new(WrapperNone { val: None }) as Box, 0)) as Factory, + ), + ( + "wrapper_float_valid", + Box::new(|| { + ( + Box::new(WrapperFloat { val: Some(1.) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_float_valid_empty", + Box::new(|| { + ( + Box::new(WrapperFloat { val: None }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_float_invalid", + Box::new(|| { + ( + Box::new(WrapperFloat { val: Some(0.) }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_double_valid", + Box::new(|| { + ( + Box::new(WrapperDouble { val: Some(1.) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_double_valid_empty", + Box::new(|| { + ( + Box::new(WrapperDouble { val: None }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_double_invalid", + Box::new(|| { + ( + Box::new(WrapperDouble { val: Some(0.) }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_int64_valid", + Box::new(|| { + ( + Box::new(WrapperInt64 { val: Some(1) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_int64_valid_empty", + Box::new(|| { + ( + Box::new(WrapperInt64 { val: None }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_int64_invalid", + Box::new(|| { + ( + Box::new(WrapperInt64 { val: Some(0) }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_int32_valid", + Box::new(|| { + ( + Box::new(WrapperInt32 { val: Some(1) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_int32_valid_empty", + Box::new(|| { + ( + Box::new(WrapperInt32 { val: None }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_int32_invalid", + Box::new(|| { + ( + Box::new(WrapperInt32 { val: Some(0) }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_uint64_valid", + Box::new(|| { + ( + Box::new(WrapperUInt64 { val: Some(1) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_uint64_valid_empty", + Box::new(|| { + ( + Box::new(WrapperUInt64 { val: None }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_uint64_invalid", + Box::new(|| { + ( + Box::new(WrapperUInt64 { val: Some(0) }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_uint32_valid", + Box::new(|| { + ( + Box::new(WrapperUInt32 { val: Some(1) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_uint32_valid_empty", + Box::new(|| { + ( + Box::new(WrapperUInt32 { val: None }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_uint32_invalid", + Box::new(|| { + ( + Box::new(WrapperUInt32 { val: Some(0) }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_bool_valid", + Box::new(|| { + ( + Box::new(WrapperBool { val: Some(true) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_bool_valid_empty", + Box::new(|| (Box::new(WrapperBool { val: None }) as Box, 0)) as Factory, + ), + ( + "wrapper_bool_invalid", + Box::new(|| { + ( + Box::new(WrapperBool { val: Some(false) }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_string_valid", + Box::new(|| { + ( + Box::new(WrapperString { + val: Some("foobar".to_string()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_string_valid_empty", + Box::new(|| { + ( + Box::new(WrapperString { val: None }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_string_invalid", + Box::new(|| { + ( + Box::new(WrapperString { + val: Some("fizzbuzz".to_string()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_bytes_valid", + Box::new(|| { + ( + Box::new(WrapperBytes { + val: Some(b"foo".to_vec()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_bytes_valid_empty", + Box::new(|| { + ( + Box::new(WrapperBytes { val: None }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_bytes_invalid", + Box::new(|| { + ( + Box::new(WrapperBytes { + val: Some(b"x".to_vec()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_required_string_valid", + Box::new(|| { + ( + Box::new(WrapperRequiredString { + val: Some("bar".to_string()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_required_string_invalid", + Box::new(|| { + ( + Box::new(WrapperRequiredString { + val: Some("foo".to_string()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_required_string_invalid_empty", + Box::new(|| { + ( + Box::new(WrapperRequiredString::default()) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_required_string_empty_valid", + Box::new(|| { + ( + Box::new(WrapperRequiredEmptyString { + val: Some("".to_string()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_required_string_empty_invalid", + Box::new(|| { + ( + Box::new(WrapperRequiredEmptyString { + val: Some("foo".to_string()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_required_string_empty_invalid_empty", + Box::new(|| { + ( + Box::new(WrapperRequiredEmptyString::default()) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_optional_string_uuid_valid", + Box::new(|| { + ( + Box::new(WrapperOptionalUuidString { + val: Some("8b72987b-024a-43b3-b4cf-647a1f925c5d".to_string()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_optional_string_uuid_valid_empty", + Box::new(|| { + ( + Box::new(WrapperOptionalUuidString::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_optional_string_uuid_invalid", + Box::new(|| { + ( + Box::new(WrapperOptionalUuidString { + val: Some("foo".to_string()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_required_float_valid", + Box::new(|| { + ( + Box::new(WrapperRequiredFloat { val: Some(1.) }) as Box, + 0, + ) + }) as Factory, + ), + ( + "wrapper_required_float_invalid", + Box::new(|| { + ( + Box::new(WrapperRequiredFloat { val: Some(-5.) }) as Box, + 1, + ) + }) as Factory, + ), + ( + "wrapper_required_float_invalid_empty", + Box::new(|| { + ( + Box::new(WrapperRequiredFloat::default()) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_none_valid", + Box::new(|| { + ( + Box::new(DurationNone { + val: Some(Duration { + seconds: 123, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_required_valid", + Box::new(|| { + ( + Box::new(DurationRequired { + val: Some(Duration::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_required_invalid", + Box::new(|| { + ( + Box::new(DurationRequired::default()) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_const_valid", + Box::new(|| { + ( + Box::new(DurationConst { + val: Some(Duration { + seconds: 3, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_const_valid_empty", + Box::new(|| (Box::new(DurationConst::default()) as Box, 0)) as Factory, + ), + ( + "duration_const_invalid", + Box::new(|| { + ( + Box::new(DurationConst { + val: Some(Duration { + nanos: 3, + seconds: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_in_valid", + Box::new(|| { + ( + Box::new(DurationIn { + val: Some(Duration { + seconds: 1, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_in_valid_empty", + Box::new(|| (Box::new(DurationIn::default()) as Box, 0)) as Factory, + ), + ( + "duration_in_invalid", + Box::new(|| { + ( + Box::new(DurationIn { + val: Some(Duration::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_not_in_valid", + Box::new(|| { + ( + Box::new(DurationNotIn { + val: Some(Duration { + nanos: 1, + seconds: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_not_in_valid_empty", + Box::new(|| (Box::new(DurationNotIn::default()) as Box, 0)) as Factory, + ), + ( + "duration_not_in_invalid", + Box::new(|| { + ( + Box::new(DurationNotIn { + val: Some(Duration::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_lt_valid", + Box::new(|| { + ( + Box::new(DurationLt { + val: Some(Duration { + nanos: -1, + seconds: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_lt_valid_empty", + Box::new(|| (Box::new(DurationLt::default()) as Box, 0)) as Factory, + ), + ( + "duration_lt_invalid_equal", + Box::new(|| { + ( + Box::new(DurationLt { + val: Some(Duration::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_lt_invalid", + Box::new(|| { + ( + Box::new(DurationLt { + val: Some(Duration { + seconds: 1, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_lte_valid", + Box::new(|| { + ( + Box::new(DurationLte { + val: Some(Duration::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_lte_valid_empty", + Box::new(|| (Box::new(DurationLte::default()) as Box, 0)) as Factory, + ), + ( + "duration_lte_valid_equal", + Box::new(|| { + ( + Box::new(DurationLte { + val: Some(Duration { + seconds: 1, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_lte_invalid", + Box::new(|| { + ( + Box::new(DurationLte { + val: Some(Duration { + seconds: 1, + nanos: 1, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_gt_valid", + Box::new(|| { + ( + Box::new(DurationGt { + val: Some(Duration { + seconds: 1, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_gt_valid_empty", + Box::new(|| (Box::new(DurationGt::default()) as Box, 0)) as Factory, + ), + ( + "duration_gt_invalid_equal", + Box::new(|| { + ( + Box::new(DurationGt { + val: Some(Duration { + nanos: 1000, + seconds: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_gt_invalid", + Box::new(|| { + ( + Box::new(DurationGt { + val: Some(Duration::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_gte_valid", + Box::new(|| { + ( + Box::new(DurationGte { + val: Some(Duration { + seconds: 3, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_gte_valid_empty", + Box::new(|| (Box::new(DurationGte::default()) as Box, 0)) as Factory, + ), + ( + "duration_gte_valid_equal", + Box::new(|| { + ( + Box::new(DurationGte { + val: Some(Duration { + nanos: 1000000, + seconds: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_gte_invalid", + Box::new(|| { + ( + Box::new(DurationGte { + val: Some(Duration { + seconds: -1, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_gt_lt_valid", + Box::new(|| { + ( + Box::new(DurationGtlt { + val: Some(Duration { + nanos: 1000, + seconds: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_gt_lt_valid_empty", + Box::new(|| (Box::new(DurationGtlt::default()) as Box, 0)) as Factory, + ), + ( + "duration_gt_lt_invalid_above", + Box::new(|| { + ( + Box::new(DurationGtlt { + val: Some(Duration { + seconds: 1000, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_gt_lt_invalid_below", + Box::new(|| { + ( + Box::new(DurationGtlt { + val: Some(Duration { + nanos: -1000, + seconds: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_gt_lt_invalid_max", + Box::new(|| { + ( + Box::new(DurationGtlt { + val: Some(Duration { + seconds: 1, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_gt_lt_invalid_min", + Box::new(|| { + ( + Box::new(DurationGtlt { + val: Some(Duration::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_exclusive_gt_lt_valid_empty", + Box::new(|| (Box::new(DurationExLtgt::default()) as Box, 0)) as Factory, + ), + ( + "duration_exclusive_gt_lt_valid_above", + Box::new(|| { + ( + Box::new(DurationExLtgt { + val: Some(Duration { + seconds: 2, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_exclusive_gt_lt_valid_below", + Box::new(|| { + ( + Box::new(DurationExLtgt { + val: Some(Duration { + nanos: -1, + seconds: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_exclusive_gt_lt_invalid", + Box::new(|| { + ( + Box::new(DurationExLtgt { + val: Some(Duration { + nanos: 1000, + seconds: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_exclusive_gt_lt_invalid_max", + Box::new(|| { + ( + Box::new(DurationExLtgt { + val: Some(Duration { + seconds: 1, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_exclusive_gt_lt_invalid_min", + Box::new(|| { + ( + Box::new(DurationExLtgt { + val: Some(Duration::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_gte_lte_valid", + Box::new(|| { + ( + Box::new(DurationGtelte { + val: Some(Duration { + seconds: 60, + nanos: 1, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_gte_lte_valid_empty", + Box::new(|| (Box::new(DurationGtelte::default()) as Box, 0)) as Factory, + ), + ( + "duration_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(DurationGtelte { + val: Some(Duration { + seconds: 3600, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(DurationGtelte { + val: Some(Duration { + seconds: 60, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_gte_lte_invalid_above", + Box::new(|| { + ( + Box::new(DurationGtelte { + val: Some(Duration { + seconds: 3600, + nanos: 1, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_gte_lte_invalid_below", + Box::new(|| { + ( + Box::new(DurationGtelte { + val: Some(Duration { + seconds: 59, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_gte_lte_valid_empty_2", + Box::new(|| { + ( + Box::new(DurationExGtelte::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(DurationExGtelte { + val: Some(Duration { + seconds: 3601, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(DurationExGtelte { + val: Some(Duration::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(DurationExGtelte { + val: Some(Duration { + seconds: 3600, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(DurationExGtelte { + val: Some(Duration { + seconds: 60, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "duration_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(DurationExGtelte { + val: Some(Duration { + seconds: 61, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "duration_fields_with_other_fields_invalid_other_field", + Box::new(|| { + ( + Box::new(DurationFieldWithOtherFields { + duration_val: None, + int_val: 12, + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_none_valid", + Box::new(|| { + ( + Box::new(TimestampNone { + val: Some(Timestamp { + seconds: 123, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_required_valid", + Box::new(|| { + ( + Box::new(TimestampRequired { + val: Some(Timestamp::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_required_invalid", + Box::new(|| { + ( + Box::new(TimestampRequired { val: None }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_const_valid", + Box::new(|| { + ( + Box::new(TimestampConst { + val: Some(Timestamp { + seconds: 3, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_const_valid_empty", + Box::new(|| (Box::new(TimestampConst::default()) as Box, 0)) as Factory, + ), + ( + "timestamp_const_invalid", + Box::new(|| { + ( + Box::new(TimestampConst { + val: Some(Timestamp { + nanos: 3, + seconds: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_lt_valid", + Box::new(|| { + ( + Box::new(TimestampLt { + val: Some(Timestamp { + seconds: -1, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_lt_valid_empty", + Box::new(|| (Box::new(TimestampLt::default()) as Box, 0)) as Factory, + ), + ( + "timestamp_lt_invalid_equal", + Box::new(|| { + ( + Box::new(TimestampLt { + val: Some(Timestamp::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_lt_invalid", + Box::new(|| { + ( + Box::new(TimestampLt { + val: Some(Timestamp { + seconds: 1, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_lte_valid", + Box::new(|| { + ( + Box::new(TimestampLte { + val: Some(Timestamp::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_lte_valid_empty", + Box::new(|| (Box::new(TimestampLte::default()) as Box, 0)) as Factory, + ), + ( + "timestamp_lte_valid_equal", + Box::new(|| { + ( + Box::new(TimestampLte { + val: Some(Timestamp { + seconds: 1, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_lte_invalid", + Box::new(|| { + ( + Box::new(TimestampLte { + val: Some(Timestamp { + seconds: 1, + nanos: 1, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gt_valid", + Box::new(|| { + ( + Box::new(TimestampGt { + val: Some(Timestamp { + seconds: 1, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gt_valid_empty", + Box::new(|| (Box::new(TimestampGt::default()) as Box, 0)) as Factory, + ), + ( + "timestamp_gt_invalid_equal", + Box::new(|| { + ( + Box::new(TimestampGt { + val: Some(Timestamp { + nanos: 1000, + seconds: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gt_invalid", + Box::new(|| { + ( + Box::new(TimestampGt { + val: Some(Timestamp::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gte_valid", + Box::new(|| { + ( + Box::new(TimestampGte { + val: Some(Timestamp { + seconds: 3, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gte_valid_empty", + Box::new(|| (Box::new(TimestampGte::default()) as Box, 0)) as Factory, + ), + ( + "timestamp_gte_valid_equal", + Box::new(|| { + ( + Box::new(TimestampGte { + val: Some(Timestamp { + nanos: 1000000, + seconds: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gte_invalid", + Box::new(|| { + ( + Box::new(TimestampGte { + val: Some(Timestamp { + seconds: -1, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gt_lt_valid", + Box::new(|| { + ( + Box::new(TimestampGtlt { + val: Some(Timestamp { + nanos: 1000, + seconds: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gt_lt_valid_empty", + Box::new(|| (Box::new(TimestampGtlt::default()) as Box, 0)) as Factory, + ), + ( + "timestamp_gt_lt_invalid_above", + Box::new(|| { + ( + Box::new(TimestampGtlt { + val: Some(Timestamp { + seconds: 1000, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gt_lt_invalid_below", + Box::new(|| { + ( + Box::new(TimestampGtlt { + val: Some(Timestamp { + seconds: -1000, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gt_lt_invalid_max", + Box::new(|| { + ( + Box::new(TimestampGtlt { + val: Some(Timestamp { + seconds: 1, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gt_lt_invalid_min", + Box::new(|| { + ( + Box::new(TimestampGtlt { + val: Some(Timestamp::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gt_lt_valid_empty", + Box::new(|| { + ( + Box::new(TimestampExLtgt::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gt_lt_valid_above", + Box::new(|| { + ( + Box::new(TimestampExLtgt { + val: Some(Timestamp { + seconds: 2, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gt_lt_valid_below", + Box::new(|| { + ( + Box::new(TimestampExLtgt { + val: Some(Timestamp { + seconds: -1, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gt_lt_invalid", + Box::new(|| { + ( + Box::new(TimestampExLtgt { + val: Some(Timestamp { + nanos: 1000, + seconds: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gt_lt_invalid_max", + Box::new(|| { + ( + Box::new(TimestampExLtgt { + val: Some(Timestamp { + seconds: 1, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gt_lt_invalid_min", + Box::new(|| { + ( + Box::new(TimestampExLtgt { + val: Some(Timestamp::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gte_lte_valid", + Box::new(|| { + ( + Box::new(TimestampGtelte { + val: Some(Timestamp { + seconds: 60, + nanos: 1, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gte_lte_valid_empty", + Box::new(|| { + ( + Box::new(TimestampGtelte::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(TimestampGtelte { + val: Some(Timestamp { + seconds: 3600, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(TimestampGtelte { + val: Some(Timestamp { + seconds: 60, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gte_lte_invalid_above", + Box::new(|| { + ( + Box::new(TimestampGtelte { + val: Some(Timestamp { + seconds: 3600, + nanos: 1, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gte_lte_invalid_below", + Box::new(|| { + ( + Box::new(TimestampGtelte { + val: Some(Timestamp { + seconds: 59, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gte_lte_valid_empty_2", + Box::new(|| { + ( + Box::new(TimestampExGtelte::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gte_lte_valid_above", + Box::new(|| { + ( + Box::new(TimestampExGtelte { + val: Some(Timestamp { + seconds: 3601, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gte_lte_valid_below", + Box::new(|| { + ( + Box::new(TimestampExGtelte { + val: Some(Timestamp::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gte_lte_valid_max", + Box::new(|| { + ( + Box::new(TimestampExGtelte { + val: Some(Timestamp { + seconds: 3600, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gte_lte_valid_min", + Box::new(|| { + ( + Box::new(TimestampExGtelte { + val: Some(Timestamp { + seconds: 60, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_exclusive_gte_lte_invalid", + Box::new(|| { + ( + Box::new(TimestampExGtelte { + val: Some(Timestamp { + seconds: 61, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_lt_now_valid", + Box::new(|| { + ( + Box::new(TimestampLtNow { + val: Some(Timestamp::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_lt_now_valid_empty", + Box::new(|| (Box::new(TimestampLtNow::default()) as Box, 0)) as Factory, + ), + ( + "timestamp_lt_now_invalid", + Box::new(|| { + ( + Box::new(TimestampLtNow { + val: Some(Timestamp { + seconds: now() + 7200, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gt_now_valid", + Box::new(|| { + ( + Box::new(TimestampGtNow { + val: Some(Timestamp { + seconds: now() + 7200, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gt_now_valid_empty", + Box::new(|| (Box::new(TimestampGtNow::default()) as Box, 0)) as Factory, + ), + ( + "timestamp_gt_now_invalid", + Box::new(|| { + ( + Box::new(TimestampGtNow { + val: Some(Timestamp::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_within_valid", + Box::new(|| { + ( + Box::new(TimestampWithin { + val: Some(Timestamp { + seconds: now(), + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_within_valid_empty", + Box::new(|| { + ( + Box::new(TimestampWithin::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_within_invalid_below", + Box::new(|| { + ( + Box::new(TimestampWithin { + val: Some(Timestamp::default()), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_within_invalid_above", + Box::new(|| { + ( + Box::new(TimestampWithin { + val: Some(Timestamp { + seconds: now() + 7200, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_lt_now_within_valid", + Box::new(|| { + ( + Box::new(TimestampLtNowWithin { + val: Some(Timestamp { + seconds: now() - 1800, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_lt_now_within_valid_empty", + Box::new(|| { + ( + Box::new(TimestampLtNowWithin::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_lt_now_within_invalid_lt", + Box::new(|| { + ( + Box::new(TimestampLtNowWithin { + val: Some(Timestamp { + seconds: now() + 1800, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_lt_now_within_invalid_within", + Box::new(|| { + ( + Box::new(TimestampLtNowWithin { + val: Some(Timestamp { + seconds: now() - 7200, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gt_now_within_valid", + Box::new(|| { + ( + Box::new(TimestampGtNowWithin { + val: Some(Timestamp { + seconds: now() + 1800, + nanos: 0, + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gt_now_within_valid_empty", + Box::new(|| { + ( + Box::new(TimestampGtNowWithin::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "timestamp_gt_now_within_invalid_gt", + Box::new(|| { + ( + Box::new(TimestampGtNowWithin { + val: Some(Timestamp { + seconds: now() - 1800, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "timestamp_gt_now_within_invalid_within", + Box::new(|| { + ( + Box::new(TimestampGtNowWithin { + val: Some(Timestamp { + seconds: now() + 7200, + nanos: 0, + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "any_none_valid", + Box::new(|| { + ( + Box::new(AnyNone { + val: Some(Any::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "any_required_valid", + Box::new(|| { + ( + Box::new(AnyRequired { + val: Some(Any::default()), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "any_required_invalid", + Box::new(|| (Box::new(AnyRequired { val: None }) as Box, 1)) as Factory, + ), + ( + "any_in_valid", + Box::new(|| { + ( + Box::new(AnyIn { + val: Some(Any { + type_url: "type.googleapis.com/google.protobuf.Duration".to_string(), + ..Any::default() + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "any_in_valid_empty", + Box::new(|| (Box::new(AnyIn::default()) as Box, 0)) as Factory, + ), + ( + "any_in_invalid", + Box::new(|| { + ( + Box::new(AnyIn { + val: Some(Any { + type_url: "type.googleapis.com/google.protobuf.Timestamp".to_string(), + ..Any::default() + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "any_not_in_valid", + Box::new(|| { + ( + Box::new(AnyNotIn { + val: Some(Any { + type_url: "type.googleapis.com/google.protobuf.Duration".to_string(), + ..Any::default() + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "any_not_in_valid_empty", + Box::new(|| (Box::new(AnyNotIn::default()) as Box, 0)) as Factory, + ), + ( + "any_not_in_invalid", + Box::new(|| { + ( + Box::new(AnyNotIn { + val: Some(Any { + type_url: "type.googleapis.com/google.protobuf.Timestamp".to_string(), + ..Any::default() + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ( + "kitchensink_field_valid", + Box::new(|| { + ( + Box::new(KitchenSinkMessage { + val: Some(ComplexTestMsg { + r#const: "abcd".to_string(), + int_const: 5, + bool_const: false, + float_val: Some(1.), + dur_val: Some(Duration { + seconds: 3, + nanos: 0, + }), + ts_val: Some(Timestamp { + seconds: 17, + nanos: 0, + }), + float_const: 7., + double_in: 123., + enum_const: ComplexTestEnum::ComplexTwo.into(), + any_val: Some(Any { + type_url: "type.googleapis.com/google.protobuf.Duration" + .to_string(), + ..Any::default() + }), + rep_ts_val: vec![Timestamp { + seconds: 3, + nanos: 0, + }], + map_val: HashMap::from([(-1, "a".to_string()), (-2, "b".to_string())]), + bytes_val: b"\x00\x99".to_vec(), + o: Some(complex_test_msg::O::X("foobar".to_string())), + ..ComplexTestMsg::default() + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "kitchensink_valid_unset", + Box::new(|| { + ( + Box::new(KitchenSinkMessage::default()) as Box, + 0, + ) + }) as Factory, + ), + ( + "kitchensink_field_invalid", + Box::new(|| { + ( + Box::new(KitchenSinkMessage { + val: Some(ComplexTestMsg::default()), + }) as Box, + 7, + ) + }) as Factory, + ), + ( + "kitchensink_field_embedded_invalid", + Box::new(|| { + ( + Box::new(KitchenSinkMessage { + val: Some(ComplexTestMsg { + another: Some(Box::new(ComplexTestMsg::default())), + ..ComplexTestMsg::default() + }), + }) as Box, + 14, + ) + }) as Factory, + ), + ( + "kitchensink_field_invalid_transitive", + Box::new(|| { + ( + Box::new(KitchenSinkMessage { + val: Some(ComplexTestMsg { + r#const: "abcd".to_string(), + bool_const: true, + nested: Some(Box::new(ComplexTestMsg::default())), + ..ComplexTestMsg::default() + }), + }) as Box, + 14, + ) + }) as Factory, + ), + ( + "kitchensink_many_all_non_message_fields_invalid", + Box::new(|| { + ( + Box::new(KitchenSinkMessage { + val: Some(ComplexTestMsg { + bool_const: true, + float_val: Some(0.), + ts_val: Some(Timestamp::default()), + float_const: 8., + any_val: Some(Any { + type_url: "asdf".to_string(), + ..Any::default() + }), + rep_ts_val: vec![Timestamp { + seconds: 0, + nanos: 1, + }], + ..ComplexTestMsg::default() + }), + }) as Box, + 13, + ) + }) as Factory, + ), + ( + "nested_wkt_uuid_field_valid", + Box::new(|| { + ( + Box::new(WktLevelOne { + two: Some(cases::wkt_level_one::WktLevelTwo { + three: Some(cases::wkt_level_one::wkt_level_two::WktLevelThree { + uuid: "f81d16ef-40e2-40c6-bebc-89aaf5292f9a".to_string(), + }), + }), + }) as Box, + 0, + ) + }) as Factory, + ), + ( + "nested_wkt_uuid_field_invalid", + Box::new(|| { + ( + Box::new(WktLevelOne { + two: Some(cases::wkt_level_one::WktLevelTwo { + three: Some(cases::wkt_level_one::wkt_level_two::WktLevelThree { + uuid: "not-a-valid-uuid".to_string(), + }), + }), + }) as Box, + 1, + ) + }) as Factory, + ), + ]) +}); diff --git a/protoc-gen-prost-validate/tests/cases/mod.rs b/protoc-gen-prost-validate/tests/cases/mod.rs new file mode 100644 index 0000000..21d9ea6 --- /dev/null +++ b/protoc-gen-prost-validate/tests/cases/mod.rs @@ -0,0 +1,11 @@ +mod cases; +#[allow(dead_code)] +mod gen; +pub use cases::CASES; +use prost_validate::Validator; + +pub type Factory = Box (Box, i32) + Send + Sync>; + +pub fn now() -> i64 { + time::OffsetDateTime::now_utc().unix_timestamp() +} diff --git a/protoc-gen-prost-validate/tests/harness.rs b/protoc-gen-prost-validate/tests/harness.rs new file mode 100644 index 0000000..3ff57c2 --- /dev/null +++ b/protoc-gen-prost-validate/tests/harness.rs @@ -0,0 +1,1222 @@ +mod cases; + +#[allow(unused)] +macro_rules! test_cases { + ($($name:ident,)*) => { + $( + #[test] + fn $name() { + use prost_validate::Validator; + use crate::cases::CASES; + let (message, failures) = CASES.get(stringify!($name)).unwrap()(); + match Validator::validate(&*message) { + Err(err) => { + println!("{}", err); + assert!(failures > 0, "unexpected validation failure: {err}"); + }, + Ok(_) => assert_eq!(failures, 0, "unexpected validation success"), + } + } + )* + } +} + +#[cfg(test)] +mod float { + test_cases![ + float_none_valid, + float_const_valid, + float_const_invalid, + float_in_valid, + float_in_invalid, + float_not_in_valid, + float_not_in_invalid, + float_lt_valid, + float_lt_invalid_equal, + float_lt_invalid, + float_lte_valid, + float_lte_valid_equal, + float_lte_invalid, + float_gt_valid, + float_gt_invalid_equal, + float_gt_invalid, + float_gte_valid, + float_gte_valid_equal, + float_gte_invalid, + float_gt_lt_valid, + float_gt_lt_invalid_above, + float_gt_lt_invalid_below, + float_gt_lt_invalid_max, + float_gt_lt_invalid_min, + float_exclusive_gt_lt_valid_above, + float_exclusive_gt_lt_valid_below, + float_exclusive_gt_lt_invalid, + float_exclusive_gt_lt_invalid_max, + float_exclusive_gt_lt_invalid_min, + float_gte_lte_valid, + float_gte_lte_valid_max, + float_gte_lte_valid_min, + float_gte_lte_invalid_above, + float_gte_lte_invalid_below, + float_exclusive_gte_lte_valid_above, + float_exclusive_gte_lte_valid_below, + float_exclusive_gte_lte_valid_max, + float_exclusive_gte_lte_valid_min, + float_exclusive_gte_lte_invalid, + float_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod double { + + test_cases![ + double_none_valid, + double_const_valid, + double_const_invalid, + double_in_valid, + double_in_invalid, + double_not_in_valid, + double_not_in_invalid, + double_lt_valid, + double_lt_invalid_equal, + double_lt_invalid, + double_lte_valid, + double_lte_valid_equal, + double_lte_invalid, + double_gt_valid, + double_gt_invalid_equal, + double_gt_invalid, + double_gte_valid, + double_gte_valid_equal, + double_gte_invalid, + double_gt_lt_valid, + double_gt_lt_invalid_above, + double_gt_lt_invalid_below, + double_gt_lt_invalid_max, + double_gt_lt_invalid_min, + double_exclusive_gt_lt_valid_above, + double_exclusive_gt_lt_valid_below, + double_exclusive_gt_lt_invalid, + double_exclusive_gt_lt_invalid_max, + double_exclusive_gt_lt_invalid_min, + double_gte_lte_valid, + double_gte_lte_valid_max, + double_gte_lte_valid_min, + double_gte_lte_invalid_above, + double_gte_lte_invalid_below, + double_exclusive_gte_lte_valid_above, + double_exclusive_gte_lte_valid_below, + double_exclusive_gte_lte_valid_max, + double_exclusive_gte_lte_valid_min, + double_exclusive_gte_lte_invalid, + double_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod int32 { + + test_cases![ + int32_none_valid, + int32_const_valid, + int32_const_invalid, + int32_in_valid, + int32_in_invalid, + int32_not_in_valid, + int32_not_in_invalid, + int32_lt_valid, + int32_lt_invalid_equal, + int32_lt_invalid, + int32_lte_valid, + int32_lte_valid_equal, + int32_lte_invalid, + int32_gt_valid, + int32_gt_invalid_equal, + int32_gt_invalid, + int32_gte_valid, + int32_gte_valid_equal, + int32_gte_invalid, + int32_gt_lt_valid, + int32_gt_lt_invalid_above, + int32_gt_lt_invalid_below, + int32_gt_lt_invalid_max, + int32_gt_lt_invalid_min, + int32_exclusive_gt_lt_valid_above, + int32_exclusive_gt_lt_valid_below, + int32_exclusive_gt_lt_invalid, + int32_exclusive_gt_lt_invalid_max, + int32_exclusive_gt_lt_invalid_min, + int32_gte_lte_valid, + int32_gte_lte_valid_max, + int32_gte_lte_valid_min, + int32_gte_lte_invalid_above, + int32_gte_lte_invalid_below, + int32_exclusive_gte_lte_valid_above, + int32_exclusive_gte_lte_valid_below, + int32_exclusive_gte_lte_valid_max, + int32_exclusive_gte_lte_valid_min, + int32_exclusive_gte_lte_invalid, + int32_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod int64 { + + test_cases![ + int64_none_valid, + int64_const_valid, + int64_const_invalid, + int64_in_valid, + int64_in_invalid, + int64_not_in_valid, + int64_not_in_invalid, + int64_lt_valid, + int64_lt_invalid_equal, + int64_lt_invalid, + int64_lte_valid, + int64_lte_valid_equal, + int64_lte_invalid, + int64_gt_valid, + int64_gt_invalid_equal, + int64_gt_invalid, + int64_gte_valid, + int64_gte_valid_equal, + int64_gte_invalid, + int64_gt_lt_valid, + int64_gt_lt_invalid_above, + int64_gt_lt_invalid_below, + int64_gt_lt_invalid_max, + int64_gt_lt_invalid_min, + int64_exclusive_gt_lt_valid_above, + int64_exclusive_gt_lt_valid_below, + int64_exclusive_gt_lt_invalid, + int64_exclusive_gt_lt_invalid_max, + int64_exclusive_gt_lt_invalid_min, + int64_gte_lte_valid, + int64_gte_lte_valid_max, + int64_gte_lte_valid_min, + int64_gte_lte_invalid_above, + int64_gte_lte_invalid_below, + int64_exclusive_gte_lte_valid_above, + int64_exclusive_gte_lte_valid_below, + int64_exclusive_gte_lte_valid_max, + int64_exclusive_gte_lte_valid_min, + int64_exclusive_gte_lte_invalid, + int64_ignore_empty_gte_lte_valid, + int64_optional_lte_valid, + int64_optional_lte_valid_equal, + int64_optional_lte_valid_unset, + ]; +} +#[cfg(test)] +mod uint32 { + + test_cases![ + uint32_none_valid, + uint32_const_valid, + uint32_const_invalid, + uint32_in_valid, + uint32_in_invalid, + uint32_not_in_valid, + uint32_not_in_invalid, + uint32_lt_valid, + uint32_lt_invalid_equal, + uint32_lt_invalid, + uint32_lte_valid, + uint32_lte_valid_equal, + uint32_lte_invalid, + uint32_gt_valid, + uint32_gt_invalid_equal, + uint32_gt_invalid, + uint32_gte_valid, + uint32_gte_valid_equal, + uint32_gte_invalid, + uint32_gt_lt_valid, + uint32_gt_lt_invalid_above, + uint32_gt_lt_invalid_below, + uint32_gt_lt_invalid_max, + uint32_gt_lt_invalid_min, + uint32_exclusive_gt_lt_valid_above, + uint32_exclusive_gt_lt_valid_below, + uint32_exclusive_gt_lt_invalid, + uint32_exclusive_gt_lt_invalid_max, + uint32_exclusive_gt_lt_invalid_min, + uint32_gte_lte_valid, + uint32_gte_lte_valid_max, + uint32_gte_lte_valid_min, + uint32_gte_lte_invalid_above, + uint32_gte_lte_invalid_below, + uint32_exclusive_gte_lte_valid_above, + uint32_exclusive_gte_lte_valid_below, + uint32_exclusive_gte_lte_valid_max, + uint32_exclusive_gte_lte_valid_min, + uint32_exclusive_gte_lte_invalid, + uint32_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod uint64 { + + test_cases![ + uint64_none_valid, + uint64_const_valid, + uint64_const_invalid, + uint64_in_valid, + uint64_in_invalid, + uint64_not_in_valid, + uint64_not_in_invalid, + uint64_lt_valid, + uint64_lt_invalid_equal, + uint64_lt_invalid, + uint64_lte_valid, + uint64_lte_valid_equal, + uint64_lte_invalid, + uint64_gt_valid, + uint64_gt_invalid_equal, + uint64_gt_invalid, + uint64_gte_valid, + uint64_gte_valid_equal, + uint64_gte_invalid, + uint64_gt_lt_valid, + uint64_gt_lt_invalid_above, + uint64_gt_lt_invalid_below, + uint64_gt_lt_invalid_max, + uint64_gt_lt_invalid_min, + uint64_exclusive_gt_lt_valid_above, + uint64_exclusive_gt_lt_valid_below, + uint64_exclusive_gt_lt_invalid, + uint64_exclusive_gt_lt_invalid_max, + uint64_exclusive_gt_lt_invalid_min, + uint64_gte_lte_valid, + uint64_gte_lte_valid_max, + uint64_gte_lte_valid_min, + uint64_gte_lte_invalid_above, + uint64_gte_lte_invalid_below, + uint64_exclusive_gte_lte_valid_above, + uint64_exclusive_gte_lte_valid_below, + uint64_exclusive_gte_lte_valid_max, + uint64_exclusive_gte_lte_valid_min, + uint64_exclusive_gte_lte_invalid, + uint64_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod sint32 { + + test_cases![ + sint32_none_valid, + sint32_const_valid, + sint32_const_invalid, + sint32_in_valid, + sint32_in_invalid, + sint32_not_in_valid, + sint32_not_in_invalid, + sint32_lt_valid, + sint32_lt_invalid_equal, + sint32_lt_invalid, + sint32_lte_valid, + sint32_lte_valid_equal, + sint32_lte_invalid, + sint32_gt_valid, + sint32_gt_invalid_equal, + sint32_gt_invalid, + sint32_gte_valid, + sint32_gte_valid_equal, + sint32_gte_invalid, + sint32_gt_lt_valid, + sint32_gt_lt_invalid_above, + sint32_gt_lt_invalid_below, + sint32_gt_lt_invalid_max, + sint32_gt_lt_invalid_min, + sint32_exclusive_gt_lt_valid_above, + sint32_exclusive_gt_lt_valid_below, + sint32_exclusive_gt_lt_invalid, + sint32_exclusive_gt_lt_invalid_max, + sint32_exclusive_gt_lt_invalid_min, + sint32_gte_lte_valid, + sint32_gte_lte_valid_max, + sint32_gte_lte_valid_min, + sint32_gte_lte_invalid_above, + sint32_gte_lte_invalid_below, + sint32_exclusive_gte_lte_valid_above, + sint32_exclusive_gte_lte_valid_below, + sint32_exclusive_gte_lte_valid_max, + sint32_exclusive_gte_lte_valid_min, + sint32_exclusive_gte_lte_invalid, + sint32_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod sint64 { + + test_cases![ + sint64_none_valid, + sint64_const_valid, + sint64_const_invalid, + sint64_in_valid, + sint64_in_invalid, + sint64_not_in_valid, + sint64_not_in_invalid, + sint64_lt_valid, + sint64_lt_invalid_equal, + sint64_lt_invalid, + sint64_lte_valid, + sint64_lte_valid_equal, + sint64_lte_invalid, + sint64_gt_valid, + sint64_gt_invalid_equal, + sint64_gt_invalid, + sint64_gte_valid, + sint64_gte_valid_equal, + sint64_gte_invalid, + sint64_gt_lt_valid, + sint64_gt_lt_invalid_above, + sint64_gt_lt_invalid_below, + sint64_gt_lt_invalid_max, + sint64_gt_lt_invalid_min, + sint64_exclusive_gt_lt_valid_above, + sint64_exclusive_gt_lt_valid_below, + sint64_exclusive_gt_lt_invalid, + sint64_exclusive_gt_lt_invalid_max, + sint64_exclusive_gt_lt_invalid_min, + sint64_gte_lte_valid, + sint64_gte_lte_valid_max, + sint64_gte_lte_valid_min, + sint64_gte_lte_invalid_above, + sint64_gte_lte_invalid_below, + sint64_exclusive_gte_lte_valid_above, + sint64_exclusive_gte_lte_valid_below, + sint64_exclusive_gte_lte_valid_max, + sint64_exclusive_gte_lte_valid_min, + sint64_exclusive_gte_lte_invalid, + sint64_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod fixed32 { + + test_cases![ + fixed32_none_valid, + fixed32_const_valid, + fixed32_const_invalid, + fixed32_in_valid, + fixed32_in_invalid, + fixed32_not_in_valid, + fixed32_not_in_invalid, + fixed32_lt_valid, + fixed32_lt_invalid_equal, + fixed32_lt_invalid, + fixed32_lte_valid, + fixed32_lte_valid_equal, + fixed32_lte_invalid, + fixed32_gt_valid, + fixed32_gt_invalid_equal, + fixed32_gt_invalid, + fixed32_gte_valid, + fixed32_gte_valid_equal, + fixed32_gte_invalid, + fixed32_gt_lt_valid, + fixed32_gt_lt_invalid_above, + fixed32_gt_lt_invalid_below, + fixed32_gt_lt_invalid_max, + fixed32_gt_lt_invalid_min, + fixed32_exclusive_gt_lt_valid_above, + fixed32_exclusive_gt_lt_valid_below, + fixed32_exclusive_gt_lt_invalid, + fixed32_exclusive_gt_lt_invalid_max, + fixed32_exclusive_gt_lt_invalid_min, + fixed32_gte_lte_valid, + fixed32_gte_lte_valid_max, + fixed32_gte_lte_valid_min, + fixed32_gte_lte_invalid_above, + fixed32_gte_lte_invalid_below, + fixed32_exclusive_gte_lte_valid_above, + fixed32_exclusive_gte_lte_valid_below, + fixed32_exclusive_gte_lte_valid_max, + fixed32_exclusive_gte_lte_valid_min, + fixed32_exclusive_gte_lte_invalid, + fixed32_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod fixed64 { + + test_cases![ + fixed64_none_valid, + fixed64_const_valid, + fixed64_const_invalid, + fixed64_in_valid, + fixed64_in_invalid, + fixed64_not_in_valid, + fixed64_not_in_invalid, + fixed64_lt_valid, + fixed64_lt_invalid_equal, + fixed64_lt_invalid, + fixed64_lte_valid, + fixed64_lte_valid_equal, + fixed64_lte_invalid, + fixed64_gt_valid, + fixed64_gt_invalid_equal, + fixed64_gt_invalid, + fixed64_gte_valid, + fixed64_gte_valid_equal, + fixed64_gte_invalid, + fixed64_gt_lt_valid, + fixed64_gt_lt_invalid_above, + fixed64_gt_lt_invalid_below, + fixed64_gt_lt_invalid_max, + fixed64_gt_lt_invalid_min, + fixed64_exclusive_gt_lt_valid_above, + fixed64_exclusive_gt_lt_valid_below, + fixed64_exclusive_gt_lt_invalid, + fixed64_exclusive_gt_lt_invalid_max, + fixed64_exclusive_gt_lt_invalid_min, + fixed64_gte_lte_valid, + fixed64_gte_lte_valid_max, + fixed64_gte_lte_valid_min, + fixed64_gte_lte_invalid_above, + fixed64_gte_lte_invalid_below, + fixed64_exclusive_gte_lte_valid_above, + fixed64_exclusive_gte_lte_valid_below, + fixed64_exclusive_gte_lte_valid_max, + fixed64_exclusive_gte_lte_valid_min, + fixed64_exclusive_gte_lte_invalid, + fixed64_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod sfixed32 { + + test_cases![ + sfixed32_none_valid, + sfixed32_const_valid, + sfixed32_const_invalid, + sfixed32_in_valid, + sfixed32_in_invalid, + sfixed32_not_in_valid, + sfixed32_not_in_invalid, + sfixed32_lt_valid, + sfixed32_lt_invalid_equal, + sfixed32_lt_invalid, + sfixed32_lte_valid, + sfixed32_lte_valid_equal, + sfixed32_lte_invalid, + sfixed32_gt_valid, + sfixed32_gt_invalid_equal, + sfixed32_gt_invalid, + sfixed32_gte_valid, + sfixed32_gte_valid_equal, + sfixed32_gte_invalid, + sfixed32_gt_lt_valid, + sfixed32_gt_lt_invalid_above, + sfixed32_gt_lt_invalid_below, + sfixed32_gt_lt_invalid_max, + sfixed32_gt_lt_invalid_min, + sfixed32_exclusive_gt_lt_valid_above, + sfixed32_exclusive_gt_lt_valid_below, + sfixed32_exclusive_gt_lt_invalid, + sfixed32_exclusive_gt_lt_invalid_max, + sfixed32_exclusive_gt_lt_invalid_min, + sfixed32_gte_lte_valid, + sfixed32_gte_lte_valid_max, + sfixed32_gte_lte_valid_min, + sfixed32_gte_lte_invalid_above, + sfixed32_gte_lte_invalid_below, + sfixed32_exclusive_gte_lte_valid_above, + sfixed32_exclusive_gte_lte_valid_below, + sfixed32_exclusive_gte_lte_valid_max, + sfixed32_exclusive_gte_lte_valid_min, + sfixed32_exclusive_gte_lte_invalid, + sfixed32_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod sfixed64 { + + test_cases![ + sfixed64_none_valid, + sfixed64_const_valid, + sfixed64_const_invalid, + sfixed64_in_valid, + sfixed64_in_invalid, + sfixed64_not_in_valid, + sfixed64_not_in_invalid, + sfixed64_lt_valid, + sfixed64_lt_invalid_equal, + sfixed64_lt_invalid, + sfixed64_lte_valid, + sfixed64_lte_valid_equal, + sfixed64_lte_invalid, + sfixed64_gt_valid, + sfixed64_gt_invalid_equal, + sfixed64_gt_invalid, + sfixed64_gte_valid, + sfixed64_gte_valid_equal, + sfixed64_gte_invalid, + sfixed64_gt_lt_valid, + sfixed64_gt_lt_invalid_above, + sfixed64_gt_lt_invalid_below, + sfixed64_gt_lt_invalid_max, + sfixed64_gt_lt_invalid_min, + sfixed64_exclusive_gt_lt_valid_above, + sfixed64_exclusive_gt_lt_valid_below, + sfixed64_exclusive_gt_lt_invalid, + sfixed64_exclusive_gt_lt_invalid_max, + sfixed64_exclusive_gt_lt_invalid_min, + sfixed64_gte_lte_valid, + sfixed64_gte_lte_valid_max, + sfixed64_gte_lte_valid_min, + sfixed64_gte_lte_invalid_above, + sfixed64_gte_lte_invalid_below, + sfixed64_exclusive_gte_lte_valid_above, + sfixed64_exclusive_gte_lte_valid_below, + sfixed64_exclusive_gte_lte_valid_max, + sfixed64_exclusive_gte_lte_valid_min, + sfixed64_exclusive_gte_lte_invalid, + sfixed64_ignore_empty_gte_lte_valid, + ]; +} +#[cfg(test)] +mod bool { + + test_cases![ + bool_none_valid, + bool_const_true_valid, + bool_const_true_invalid, + bool_const_false_valid, + bool_const_false_invalid, + ]; +} +#[cfg(test)] +mod string { + + test_cases![ + string_none_valid, + string_const_valid, + string_const_invalid, + string_in_valid, + string_in_invalid, + string_not_in_valid, + string_not_in_invalid, + string_len_valid, + string_len_valid_multibyte, + string_len_invalid_lt, + string_len_invalid_gt, + string_len_invalid_multibyte, + string_min_len_valid, + string_min_len_valid_min, + string_min_len_invalid, + string_min_len_invalid_multibyte, + string_max_len_valid, + string_max_len_valid_max, + string_max_len_valid_multibyte, + string_max_len_invalid, + string_min_max_len_valid, + string_min_max_len_valid_min, + string_min_max_len_valid_max, + string_min_max_len_valid_multibyte, + string_min_max_len_invalid_below, + string_min_max_len_invalid_above, + string_equal_min_max_len_valid, + string_equal_min_max_len_invalid, + string_len_bytes_valid, + string_len_bytes_invalid_lt, + string_len_bytes_invalid_gt, + string_len_bytes_invalid_multibyte, + string_min_bytes_valid, + string_min_bytes_valid_min, + string_min_bytes_valid_multibyte, + string_min_bytes_invalid, + string_max_bytes_valid, + string_max_bytes_valid_max, + string_max_bytes_invalid, + string_max_bytes_invalid_multibyte, + string_min_max_bytes_valid, + string_min_max_bytes_valid_min, + string_min_max_bytes_valid_max, + string_min_max_bytes_valid_multibyte, + string_min_max_bytes_invalid_below, + string_min_max_bytes_invalid_above, + string_equal_min_max_bytes_valid, + string_equal_min_max_bytes_invalid, + string_pattern_valid, + string_pattern_invalid, + string_pattern_invalid_empty, + string_pattern_invalid_null, + string_pattern_escapes_valid, + string_pattern_escapes_invalid, + string_pattern_escapes_invalid_empty, + string_prefix_valid, + string_prefix_valid_only, + string_prefix_invalid, + string_prefix_invalid_case_sensitive, + string_contains_valid, + string_contains_valid_only, + string_contains_invalid, + string_contains_invalid_case_sensitive, + string_not_contains_valid, + string_not_contains_valid_case_sensitive, + string_not_contains_invalid, + string_not_contains_invalid_equal, + string_suffix_valid, + string_suffix_valid_only, + string_suffix_invalid, + string_suffix_invalid_case_sensitive, + string_email_valid, + string_email_valid_name, + string_email_invalid, + string_email_invalid_local_segment_too_long, + string_email_invalid_hostname_too_long, + string_email_invalid_bad_hostname, + string_email_empty, + string_address_valid_hostname, + string_address_valid_hostname_uppercase, + string_address_valid_hostname_hyphens, + string_address_valid_hostname_trailing_dot, + string_address_invalid_hostname, + string_address_invalid_hostname_underscore, + string_address_invalid_hostname_too_long, + string_address_invalid_hostname_trailing_hyphens, + string_address_invalid_hostname_leading_hyphens, + string_address_invalid_hostname_empty, + string_address_invalid_hostname_idns, + string_address_valid_ip_v4, + string_address_valid_ip_v6, + string_address_invalid_ip, + string_hostname_valid, + string_hostname_valid_uppercase, + string_hostname_valid_hyphens, + string_hostname_valid_trailing_dot, + string_hostname_invalid, + string_hostname_invalid_underscore, + string_hostname_invalid_too_long, + string_hostname_invalid_trailing_hyphens, + string_hostname_invalid_leading_hyphens, + string_hostname_invalid_empty, + string_hostname_invalid_idns, + string_ip_valid_v4, + string_ip_valid_v6, + string_ip_invalid, + string_ipv4_valid, + string_ipv4_invalid, + string_ipv4_invalid_erroneous, + string_ipv4_invalid_v6, + string_ipv6_valid, + string_ipv6_valid_collapsed, + string_ipv6_invalid, + string_ipv6_invalid_v4, + string_ipv6_invalid_erroneous, + string_uri_valid_2, + string_uri_invalid_2, + string_uri_invalid_relative, + string_uri_valid_3, + string_uri_valid_relative, + string_uri_invalid_3, + string_uuid_valid_nil, + string_uuid_valid_v1, + string_uuid_valid_v1_case_insensitive, + string_uuid_valid_v2, + string_uuid_valid_v2_case_insensitive, + string_uuid_valid_v3, + string_uuid_valid_v3_case_insensitive, + string_uuid_valid_v4, + string_uuid_valid_v4_case_insensitive, + string_uuid_valid_v5, + string_uuid_valid_v5_case_insensitive, + string_uuid_invalid, + string_uuid_invalid_bad_uuid, + string_uuid_valid_ignore_empty, + string_http_header_name_valid, + string_http_header_name_valid_2, + string_http_header_name_valid_nums, + string_http_header_name_valid_special_token, + string_http_header_name_valid_period, + string_http_header_name_invalid, + string_http_header_name_invalid_2, + string_http_header_name_invalid_space, + string_http_header_name_invalid_return, + string_http_header_name_invalid_tab, + string_http_header_name_invalid_slash, + string_http_header_value_valid, + string_http_header_value_valid_uppercase, + string_http_header_value_valid_spaces, + string_http_header_value_valid_tab, + string_http_header_value_valid_special_token, + string_http_header_value_invalid_nul, + string_http_header_value_invalid_del, + string_http_header_value_invalid, + string_non_strict_valid_header_valid, + string_non_strict_valid_header_valid_uppercase, + string_non_strict_valid_header_valid_spaces, + string_non_strict_valid_header_valid_tab, + string_non_strict_valid_header_valid_del, + string_non_strict_valid_header_invalid_nul, + string_non_strict_valid_header_invalid_cr, + string_non_strict_valid_header_invalid_nl, + ]; +} +#[cfg(test)] +mod bytes { + + test_cases![ + bytes_none_valid, + bytes_const_valid, + bytes_const_invalid, + bytes_in_valid, + bytes_in_invalid, + bytes_not_in_valid, + bytes_not_in_invalid, + bytes_len_valid, + bytes_len_invalid_lt, + bytes_len_invalid_gt, + bytes_min_len_valid, + bytes_min_len_valid_min, + bytes_min_len_invalid, + bytes_max_len_valid, + bytes_max_len_valid_max, + bytes_max_len_invalid, + bytes_min_max_len_valid, + bytes_min_max_len_valid_min, + bytes_min_max_len_valid_max, + bytes_min_max_len_invalid_below, + bytes_min_max_len_invalid_above, + bytes_equal_min_max_len_valid, + bytes_equal_min_max_len_invalid, + bytes_pattern_valid, + bytes_pattern_invalid, + bytes_pattern_invalid_empty, + bytes_prefix_valid, + bytes_prefix_valid_only, + bytes_prefix_invalid, + bytes_contains_valid, + bytes_contains_valid_only, + bytes_contains_invalid, + bytes_suffix_valid, + bytes_suffix_valid_only, + bytes_suffix_invalid, + bytes_suffix_invalid_case_sensitive, + bytes_ip_valid_v4, + bytes_ip_valid_v6, + bytes_ip_invalid, + bytes_ipv4_valid, + bytes_ipv4_invalid, + bytes_ipv4_invalid_v6, + bytes_ipv6_valid, + bytes_ipv6_invalid, + bytes_ipv6_invalid_v4, + bytes_ipv6_valid_ignore_empty, + ]; +} +#[cfg(test)] +mod r#enum { + + test_cases![ + enum_none_valid, + enum_const_valid, + enum_const_invalid, + enum_alias_const_valid, + enum_alias_const_valid_alias, + enum_alias_const_invalid, + enum_defined_only_valid, + enum_defined_only_invalid, + enum_alias_defined_only_valid, + enum_alias_defined_only_invalid, + enum_in_valid, + enum_in_invalid, + enum_alias_in_valid, + enum_alias_in_valid_alias, + enum_alias_in_invalid, + enum_not_in_valid, + enum_not_in_valid_undefined, + enum_not_in_invalid, + enum_alias_not_in_valid, + enum_alias_not_in_invalid, + enum_alias_not_in_invalid_alias, + enum_external_defined_only_valid, + enum_external_defined_only_invalid, + enum_external_in_valid, + enum_external_in_invalid, + enum_external_not_in_valid, + enum_external_not_in_invalid, + enum_external_const_valid, + enum_external_const_invalid, + enum_repeated_defined_only_valid, + enum_repeated_defined_only_invalid, + enum_repeated_external_defined_only_valid, + enum_repeated_external_defined_only_invalid, + enum_repeated_another_external_defined_only_valid, + enum_repeated_external_in_valid, + enum_repeated_external_in_invalid, + enum_repeated_external_not_in_valid, + enum_repeated_external_not_in_invalid, + enum_map_defined_only_valid, + enum_map_defined_only_invalid, + enum_map_external_defined_only_valid, + enum_map_external_defined_only_invalid, + ]; +} +#[cfg(test)] +mod message { + + test_cases![ + message_none_valid, + message_none_valid_unset, + message_disabled_valid, + message_disabled_valid_invalid_field, + message_ignored_valid, + message_ignored_valid_invalid_field, + message_field_valid, + message_field_valid_unset, + message_field_invalid, + message_field_invalid_transitive, + message_skip_valid, + message_required_valid, + message_required_valid_oneof, + message_required_invalid, + message_required_invalid_oneof, + message_cross_package_embed_none_valid, + message_cross_package_embed_none_valid_nil, + message_cross_package_embed_none_valid_empty, + message_cross_package_embed_none_invalid, + message_required_valid_2, + message_required_valid_unset, + ]; +} +#[cfg(test)] +mod repeated { + + test_cases![ + repeated_none_valid, + repeated_embed_none_valid, + repeated_embed_none_valid_nil, + repeated_embed_none_valid_empty, + repeated_embed_none_invalid, + repeated_cross_package_embed_none_valid, + repeated_cross_package_embed_none_valid_nil, + repeated_cross_package_embed_none_valid_empty, + repeated_cross_package_embed_none_invalid, + repeated_min_valid, + repeated_min_valid_equal, + repeated_min_invalid, + repeated_min_invalid_element, + repeated_max_valid, + repeated_max_valid_equal, + repeated_max_invalid, + repeated_min_max_valid, + repeated_min_max_valid_min, + repeated_min_max_valid_max, + repeated_min_max_invalid_below, + repeated_min_max_invalid_above, + repeated_exact_valid, + repeated_exact_invalid_below, + repeated_exact_invalid_above, + repeated_unique_valid, + repeated_unique_valid_empty, + repeated_unique_valid_case_sensitivity, + repeated_unique_invalid, + repeated_items_valid, + repeated_items_valid_empty, + repeated_items_valid_pattern, + repeated_items_invalid, + repeated_items_invalid_pattern, + repeated_items_invalid_in, + repeated_items_valid_in, + repeated_items_invalid_not_in, + repeated_items_valid_not_in, + repeated_items_invalid_enum_in, + repeated_items_valid_enum_in, + repeated_items_invalid_enum_not_in, + repeated_items_valid_enum_not_in, + repeated_items_invalid_embedded_enum_in, + repeated_items_valid_embedded_enum_in, + repeated_items_invalid_embedded_enum_not_in, + repeated_items_valid_embedded_enum_not_in, + repeated_items_invalid_any_in, + repeated_items_valid_any_in, + repeated_items_invalid_any_not_in, + repeated_items_valid_any_not_in, + repeated_embed_skip_valid, + repeated_embed_skip_valid_invalid_element, + repeated_min_and_items_len_valid, + repeated_min_and_items_len_invalid_min, + repeated_min_and_items_len_invalid_len, + repeated_min_and_max_items_len_valid, + repeated_min_and_max_items_len_invalid_min_len, + repeated_min_and_max_items_len_invalid_max_len, + repeated_duration_gte_valid, + repeated_duration_gte_valid_empty, + repeated_duration_gte_valid_equal, + repeated_duration_gte_invalid, + repeated_exact_valid_ignore_empty, + ]; +} +#[cfg(test)] +mod map { + + test_cases![ + map_none_valid, + map_min_pairs_valid, + map_min_pairs_valid_equal, + map_min_pairs_invalid, + map_max_pairs_valid, + map_max_pairs_valid_equal, + map_max_pairs_invalid, + map_min_max_valid, + map_min_max_valid_min, + map_min_max_valid_max, + map_min_max_invalid_below, + map_min_max_invalid_above, + map_exact_valid, + map_exact_invalid_below, + map_exact_invalid_above, + map_no_sparse_valid, + map_no_sparse_valid_empty, + // sparse maps are no longer supported, so this case is no longer possible + // "map_no_sparse_invalid", MapNoSparse{val: HashMap::from([(1, cases::map_no_sparse::Msg::default()), (2, None)])}, 1), + map_keys_valid, + map_keys_valid_empty, + map_keys_valid_pattern, + map_keys_valid_in, + map_keys_valid_not_in, + map_keys_invalid, + map_keys_invalid_pattern, + map_keys_invalid_in, + map_keys_invalid_not_in, + map_values_valid, + map_values_valid_empty, + map_values_valid_pattern, + map_values_invalid, + map_values_invalid_pattern, + map_recursive_valid, + map_recursive_invalid, + map_exact_valid_ignore_empty, + map_multiple_valid, + ]; +} +#[cfg(test)] +mod oneof { + + test_cases![ + oneof_none_valid, + oneof_none_valid_empty, + oneof_field_valid_x, + oneof_field_valid_y, + oneof_field_valid_z, + oneof_field_valid_empty, + oneof_field_invalid_x, + oneof_field_invalid_y, + oneof_filed_invalid_z, + oneof_required_valid, + oneof_require_invalid, + oneof_ignore_empty_valid_x, + oneof_ignore_empty_valid_y, + oneof_ignore_empty_valid_z, + ]; +} +#[cfg(test)] +mod wrapper { + + test_cases![ + wrapper_none_valid, + wrapper_none_valid_empty, + wrapper_float_valid, + wrapper_float_valid_empty, + wrapper_float_invalid, + wrapper_double_valid, + wrapper_double_valid_empty, + wrapper_double_invalid, + wrapper_int64_valid, + wrapper_int64_valid_empty, + wrapper_int64_invalid, + wrapper_int32_valid, + wrapper_int32_valid_empty, + wrapper_int32_invalid, + wrapper_uint64_valid, + wrapper_uint64_valid_empty, + wrapper_uint64_invalid, + wrapper_uint32_valid, + wrapper_uint32_valid_empty, + wrapper_uint32_invalid, + wrapper_bool_valid, + wrapper_bool_valid_empty, + wrapper_bool_invalid, + wrapper_string_valid, + wrapper_string_valid_empty, + wrapper_string_invalid, + wrapper_bytes_valid, + wrapper_bytes_valid_empty, + wrapper_bytes_invalid, + wrapper_required_string_valid, + wrapper_required_string_invalid, + wrapper_required_string_invalid_empty, + wrapper_required_string_empty_valid, + wrapper_required_string_empty_invalid, + wrapper_required_string_empty_invalid_empty, + wrapper_optional_string_uuid_valid, + wrapper_optional_string_uuid_valid_empty, + wrapper_optional_string_uuid_invalid, + wrapper_required_float_valid, + wrapper_required_float_invalid, + wrapper_required_float_invalid_empty, + ]; +} +#[cfg(test)] +mod duration { + + test_cases![ + duration_none_valid, + duration_required_valid, + duration_required_invalid, + duration_const_valid, + duration_const_valid_empty, + duration_const_invalid, + duration_in_valid, + duration_in_valid_empty, + duration_in_invalid, + duration_not_in_valid, + duration_not_in_valid_empty, + duration_not_in_invalid, + duration_lt_valid, + duration_lt_valid_empty, + duration_lt_invalid_equal, + duration_lt_invalid, + duration_lte_valid, + duration_lte_valid_empty, + duration_lte_valid_equal, + duration_lte_invalid, + duration_gt_valid, + duration_gt_valid_empty, + duration_gt_invalid_equal, + duration_gt_invalid, + duration_gte_valid, + duration_gte_valid_empty, + duration_gte_valid_equal, + duration_gte_invalid, + duration_gt_lt_valid, + duration_gt_lt_valid_empty, + duration_gt_lt_invalid_above, + duration_gt_lt_invalid_below, + duration_gt_lt_invalid_max, + duration_gt_lt_invalid_min, + duration_exclusive_gt_lt_valid_empty, + duration_exclusive_gt_lt_valid_above, + duration_exclusive_gt_lt_valid_below, + duration_exclusive_gt_lt_invalid, + duration_exclusive_gt_lt_invalid_max, + duration_exclusive_gt_lt_invalid_min, + duration_gte_lte_valid, + duration_gte_lte_valid_empty, + duration_gte_lte_valid_max, + duration_gte_lte_valid_min, + duration_gte_lte_invalid_above, + duration_gte_lte_invalid_below, + duration_gte_lte_valid_empty_2, + duration_exclusive_gte_lte_valid_above, + duration_exclusive_gte_lte_valid_below, + duration_exclusive_gte_lte_valid_max, + duration_exclusive_gte_lte_valid_min, + duration_exclusive_gte_lte_invalid, + duration_fields_with_other_fields_invalid_other_field, + ]; +} +#[cfg(test)] +mod timestamp { + + test_cases![ + timestamp_none_valid, + timestamp_required_valid, + timestamp_required_invalid, + timestamp_const_valid, + timestamp_const_valid_empty, + timestamp_const_invalid, + timestamp_lt_valid, + timestamp_lt_valid_empty, + timestamp_lt_invalid_equal, + timestamp_lt_invalid, + timestamp_lte_valid, + timestamp_lte_valid_empty, + timestamp_lte_valid_equal, + timestamp_lte_invalid, + timestamp_gt_valid, + timestamp_gt_valid_empty, + timestamp_gt_invalid_equal, + timestamp_gt_invalid, + timestamp_gte_valid, + timestamp_gte_valid_empty, + timestamp_gte_valid_equal, + timestamp_gte_invalid, + timestamp_gt_lt_valid, + timestamp_gt_lt_valid_empty, + timestamp_gt_lt_invalid_above, + timestamp_gt_lt_invalid_below, + timestamp_gt_lt_invalid_max, + timestamp_gt_lt_invalid_min, + timestamp_exclusive_gt_lt_valid_empty, + timestamp_exclusive_gt_lt_valid_above, + timestamp_exclusive_gt_lt_valid_below, + timestamp_exclusive_gt_lt_invalid, + timestamp_exclusive_gt_lt_invalid_max, + timestamp_exclusive_gt_lt_invalid_min, + timestamp_gte_lte_valid, + timestamp_gte_lte_valid_empty, + timestamp_gte_lte_valid_max, + timestamp_gte_lte_valid_min, + timestamp_gte_lte_invalid_above, + timestamp_gte_lte_invalid_below, + timestamp_gte_lte_valid_empty_2, + timestamp_exclusive_gte_lte_valid_above, + timestamp_exclusive_gte_lte_valid_below, + timestamp_exclusive_gte_lte_valid_max, + timestamp_exclusive_gte_lte_valid_min, + timestamp_exclusive_gte_lte_invalid, + timestamp_lt_now_valid, + timestamp_lt_now_valid_empty, + timestamp_lt_now_invalid, + timestamp_gt_now_valid, + timestamp_gt_now_valid_empty, + timestamp_gt_now_invalid, + timestamp_within_valid, + timestamp_within_valid_empty, + timestamp_within_invalid_below, + timestamp_within_invalid_above, + timestamp_lt_now_within_valid, + timestamp_lt_now_within_valid_empty, + timestamp_lt_now_within_invalid_lt, + timestamp_lt_now_within_invalid_within, + timestamp_gt_now_within_valid, + timestamp_gt_now_within_valid_empty, + timestamp_gt_now_within_invalid_gt, + timestamp_gt_now_within_invalid_within, + ]; +} +#[cfg(test)] +mod any { + + test_cases![ + any_none_valid, + any_required_valid, + any_required_invalid, + any_in_valid, + any_in_valid_empty, + any_in_invalid, + any_not_in_valid, + any_not_in_valid_empty, + any_not_in_invalid, + ]; +} +#[cfg(test)] +mod kitchensink { + + test_cases![ + kitchensink_field_valid, + kitchensink_valid_unset, + kitchensink_field_invalid, + kitchensink_field_embedded_invalid, + kitchensink_field_invalid_transitive, + kitchensink_many_all_non_message_fields_invalid, + ]; +} +#[cfg(test)] +mod nested { + + test_cases![nested_wkt_uuid_field_valid, nested_wkt_uuid_field_invalid,]; +} diff --git a/protoc-gen-prost-validate/tests/proto/buf.lock b/protoc-gen-prost-validate/tests/proto/buf.lock new file mode 100644 index 0000000..fafef03 --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/buf.lock @@ -0,0 +1,8 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: envoyproxy + repository: protoc-gen-validate + commit: daf171c6cdb54629b5f51e345a79e4dd + digest: shake256:4ae167d7eed10da5f83a3f5df8c670d249170f11b1f2fd19afda06be2cff4d47dcc95e9e4a15151ecc8ce2d3d3614caf9a04d3ad82fb768a3870dedfa9455f36 diff --git a/protoc-gen-prost-validate/tests/proto/buf.yaml b/protoc-gen-prost-validate/tests/proto/buf.yaml new file mode 100644 index 0000000..cb998d1 --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/buf.yaml @@ -0,0 +1,3 @@ +version: v1 +deps: +- buf.build/envoyproxy/protoc-gen-validate diff --git a/protoc-gen-prost-validate/tests/proto/cases/bool.proto b/protoc-gen-prost-validate/tests/proto/cases/bool.proto new file mode 100644 index 0000000..018c88e --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/bool.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; + +message BoolNone { bool val = 1; } +message BoolConstTrue { bool val = 1 [(validate.rules).bool.const = true]; } +message BoolConstFalse { bool val = 1 [(validate.rules).bool.const = false]; } diff --git a/protoc-gen-prost-validate/tests/proto/cases/bytes.proto b/protoc-gen-prost-validate/tests/proto/cases/bytes.proto new file mode 100644 index 0000000..964cef9 --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/bytes.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; + +message BytesNone { bytes val = 1; } +message BytesConst { bytes val = 1 [(validate.rules).bytes.const = "foo"]; } +message BytesIn { bytes val = 1 [(validate.rules).bytes = {in: ["bar", "baz"]}]; } +message BytesNotIn { bytes val = 1 [(validate.rules).bytes = {not_in: ["fizz", "buzz"]}]; } +message BytesLen { bytes val = 1 [(validate.rules).bytes.len = 3]; } +message BytesMinLen { bytes val = 1 [(validate.rules).bytes.min_len = 3]; } +message BytesMaxLen { bytes val = 1 [(validate.rules).bytes.max_len = 5]; } +message BytesMinMaxLen { bytes val = 1 [(validate.rules).bytes = {min_len: 3, max_len: 5}]; } +message BytesEqualMinMaxLen { bytes val = 1 [(validate.rules).bytes = {min_len: 5, max_len: 5}]; } +message BytesPattern { bytes val = 1 [(validate.rules).bytes.pattern = "^[\x00-\x7F]+$"]; } +message BytesPrefix { bytes val = 1 [(validate.rules).bytes.prefix = "\x99"]; } +message BytesContains { bytes val = 1 [(validate.rules).bytes.contains = "bar"]; } +message BytesSuffix { bytes val = 1 [(validate.rules).bytes.suffix = "buz\x7a"]; } +message BytesIP { bytes val = 1 [(validate.rules).bytes.ip = true]; } +message BytesIPv4 { bytes val = 1 [(validate.rules).bytes.ipv4 = true]; } +message BytesIPv6 { bytes val = 1 [(validate.rules).bytes.ipv6 = true]; } +message BytesIPv6Ignore { bytes val = 1 [(validate.rules).bytes = {ipv6: true, ignore_empty: true}]; } diff --git a/protoc-gen-prost-validate/tests/proto/cases/enums.proto b/protoc-gen-prost-validate/tests/proto/cases/enums.proto new file mode 100644 index 0000000..6541936 --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/enums.proto @@ -0,0 +1,71 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; +import "other_package/embed.proto"; +import "yet_another_package/embed.proto"; +import "sort/sort.proto"; + +enum TestEnum { + ZERO = 0; + ONE = 1; + TWO = 2; +} + +enum TestEnumAlias { + option allow_alias = true; + + A = 0; + B = 1; + C = 2; + + ALPHA = 0; + BETA = 1; + GAMMA = 2; +} + +message EnumNone { TestEnum val = 1; } + +message EnumConst { TestEnum val = 1 [(validate.rules).enum.const = 2];} +message EnumAliasConst { TestEnumAlias val = 1 [(validate.rules).enum.const = 2];} + +message EnumDefined { TestEnum val = 1 [(validate.rules).enum.defined_only = true];} +message EnumAliasDefined { TestEnumAlias val = 1 [(validate.rules).enum.defined_only = true];} + +message EnumIn { TestEnum val = 1 [(validate.rules).enum = { in: [0, 2]}];} +message EnumAliasIn { TestEnumAlias val = 1 [(validate.rules).enum = { in: [0, 2]}];} + +message EnumNotIn { TestEnum val = 1 [(validate.rules).enum = { not_in: [1]}];} +message EnumAliasNotIn { TestEnumAlias val = 1 [(validate.rules).enum = { not_in: [1]}]; } + +message EnumExternal { other_package.Embed.Enumerated val = 1 [(validate.rules).enum.defined_only = true]; } +message EnumExternal2 { other_package.Embed.DoubleEmbed.DoubleEnumerated val = 1 [(validate.rules).enum.defined_only = true]; } +message EnumExternal3 { + other_package.Embed.FooNumber foo = 1 [(validate.rules).enum = { in: [0, 2] }]; + yet_another_package.Embed.BarNumber bar = 2 [(validate.rules).enum = { not_in: [1] }]; +} +message EnumExternal4 { + sort.Direction sort_direction = 1 [(validate.rules).enum.const = 1]; +} + +message RepeatedEnumDefined { repeated TestEnum val = 1 [(validate.rules).repeated.items.enum.defined_only = true]; } +message RepeatedExternalEnumDefined { repeated other_package.Embed.Enumerated val = 1 [(validate.rules).repeated.items.enum.defined_only = true]; } +message RepeatedYetAnotherExternalEnumDefined { repeated yet_another_package.Embed.Enumerated val = 1 [(validate.rules).repeated.items.enum.defined_only = true]; } +message RepeatedEnumExternal { + repeated other_package.Embed.FooNumber foo = 1 [(validate.rules).repeated.items.enum = { in: [0, 2] }]; + repeated yet_another_package.Embed.BarNumber bar = 2 [(validate.rules).repeated.items.enum = { not_in: [1] }]; +} + +message MapEnumDefined { map val = 1 [(validate.rules).map.values.enum.defined_only = true]; } +message MapExternalEnumDefined { map val = 1 [(validate.rules).map.values.enum.defined_only = true]; } + +message EnumInsideOneOf { + oneof foo { + TestEnum val = 1 [(validate.rules).enum.defined_only = true]; + } + + oneof bar { + TestEnum val2 = 2 [(validate.rules).enum = {defined_only : true not_in : 0}]; + } +} diff --git a/protoc-gen-prost-validate/tests/proto/cases/filename-with-dash.proto b/protoc-gen-prost-validate/tests/proto/cases/filename-with-dash.proto new file mode 100644 index 0000000..a231245 --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/filename-with-dash.proto @@ -0,0 +1,5 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; diff --git a/protoc-gen-prost-validate/tests/proto/cases/kitchen_sink.proto b/protoc-gen-prost-validate/tests/proto/cases/kitchen_sink.proto new file mode 100644 index 0000000..e5d8a29 --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/kitchen_sink.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; + +import "google/protobuf/wrappers.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; + +enum ComplexTestEnum { + ComplexZero = 0; + ComplexONE = 1; + ComplexTWO = 2; +} + +message ComplexTestMsg { + string const = 1 [(validate.rules).string.const = "abcd"]; + ComplexTestMsg nested = 2; + int32 int_const = 3 [(validate.rules).int32.const = 5]; + bool bool_const = 4 [(validate.rules).bool.const = false]; + google.protobuf.FloatValue float_val = 5 [(validate.rules).float.gt = 0]; + google.protobuf.Duration dur_val = 6 [(validate.rules).duration.lt = {seconds: 17}, (validate.rules).duration.required = true]; + google.protobuf.Timestamp ts_val = 7 [(validate.rules).timestamp.gt = {seconds: 7}]; + ComplexTestMsg another = 8; + float float_const = 9 [(validate.rules).float.lt = 8]; + double double_in = 10 [(validate.rules).double = {in: [456.789, 123]}]; + ComplexTestEnum enum_const = 11 [(validate.rules).enum.const = 2]; + google.protobuf.Any any_val = 12 [(validate.rules).any = {in: ["type.googleapis.com/google.protobuf.Duration"]}]; + repeated google.protobuf.Timestamp rep_ts_val = 13 [(validate.rules).repeated = { items { timestamp { gte { nanos: 1000000}}}}]; + map map_val = 14 [(validate.rules).map.keys.sint32.lt = 0]; + bytes bytes_val = 15 [(validate.rules).bytes.const = "\x00\x99"]; + oneof o { + option (validate.required) = true; + + string x = 16; + int32 y = 17; + } +} + +message KitchenSinkMessage { ComplexTestMsg val = 1; } diff --git a/protoc-gen-prost-validate/tests/proto/cases/maps.proto b/protoc-gen-prost-validate/tests/proto/cases/maps.proto new file mode 100644 index 0000000..46c973e --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/maps.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; + +message MapNone { map val = 1; } + +message MapMin { map val = 1 [(validate.rules).map.min_pairs = 2]; } +message MapMax { map val = 1 [(validate.rules).map.max_pairs = 3]; } +message MapMinMax { map val = 1 [(validate.rules).map = {min_pairs: 2, max_pairs: 4}]; } +message MapExact { map val = 1 [(validate.rules).map = {min_pairs: 3, max_pairs: 3}]; } + +message MapNoSparse { + map val = 1 [(validate.rules).map.no_sparse = true]; + message Msg {} +} + +message MapKeys { map val = 1 [(validate.rules).map.keys.sint64.lt = 0]; } +message MapValues { map val = 1 [(validate.rules).map.values.string.min_len = 3]; } + +message MapKeysPattern { map val = 1 [(validate.rules).map.keys.string.pattern = "(?i)^[a-z0-9]+$"]; } +message MapValuesPattern { map val = 1 [(validate.rules).map.values.string.pattern = "(?i)^[a-z0-9]+$"]; } + +message MapRecursive { + map val = 1; + message Msg { + string val = 1 [(validate.rules).string.min_len = 3]; + } +} + +message MapExactIgnore { map val = 1 [(validate.rules).map = {min_pairs: 3, max_pairs: 3, ignore_empty: true}]; } + +message MultipleMaps { + map first = 1 [(validate.rules).map.keys.uint32.gt = 0]; + map second = 2 [(validate.rules).map.keys.int32.lt = 0]; + map third = 3 [(validate.rules).map.keys.int32.gt = 0]; +} + +message MapKeysIn {map val = 1 [(validate.rules).map.keys.string = {in: ["foo", "bar"]}]; } +message MapKeysNotIn {map val = 1 [(validate.rules).map.keys.string = {not_in: ["foo", "bar"]}]; } diff --git a/protoc-gen-prost-validate/tests/proto/cases/messages.proto b/protoc-gen-prost-validate/tests/proto/cases/messages.proto new file mode 100644 index 0000000..568af2d --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/messages.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "other_package/embed.proto"; + +import "validate/validate.proto"; + +message TestMsg { + string const = 1 [(validate.rules).string.const = "foo"]; + TestMsg nested = 2; +} + +message MessageNone { + NoneMsg val = 1; + message NoneMsg {} +} + +message MessageDisabled { + option (validate.disabled) = true; + uint64 val = 1 [(validate.rules).uint64.gt = 123]; +} + +message MessageIgnored { + option (validate.ignored) = true; + uint64 val = 1 [(validate.rules).uint64.gt = 123]; +} + +message Message { TestMsg val = 1; } +message MessageCrossPackage { tests.harness.cases.other_package.Embed val = 1; } +message MessageSkip { TestMsg val = 1 [(validate.rules).message.skip = true];} +message MessageRequired { TestMsg val = 1 [(validate.rules).message.required = true]; } +message MessageRequiredButOptional { optional TestMsg val = 1 [(validate.rules).message.required = true]; } + +message MessageRequiredOneof { + oneof one { + option (validate.required) = true; + TestMsg val = 1 [(validate.rules).message.required = true]; + } +} + +message MessageWith3dInside {} diff --git a/protoc-gen-prost-validate/tests/proto/cases/nested.proto b/protoc-gen-prost-validate/tests/proto/cases/nested.proto new file mode 100644 index 0000000..098d3b2 --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/nested.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; + +package company.product.v1; + +import "validate/validate.proto"; + +enum X { + e1 = 0; + e2 = 1; + e3 = 2; +} + +message A { + enum Y { + e1 = 0; + e2 = 1; + e3 = 2; + } + message B { + enum Z { + e1 = 0; + e2 = 1; + e3 = 2; + } + oneof o { + option (validate.required) = true; + string s = 1 [(validate.rules).string.min_len = 1]; + int32 i = 2 [(validate.rules).int32.lt = 10]; + Y y = 3 [(validate.rules).enum.defined_only = true]; + } + message C { + oneof o { + option (validate.required) = true; + string s = 1 [(validate.rules).string.min_len = 1]; + int32 i = 2 [(validate.rules).int32.lt = 10]; + Z z = 3 [(validate.rules).enum.defined_only = true]; + } + } + Z z = 4 [(validate.rules).enum.defined_only = true]; + } + oneof o { + option (validate.required) = true; + string s = 1 [(validate.rules).string.min_len = 1]; + int32 i = 2 [(validate.rules).int32.lt = 10]; + Y y2 = 3 [(validate.rules).enum.defined_only = true]; + } + X x = 4 [(validate.rules).enum.defined_only = true]; + Y y = 5 [(validate.rules).enum.defined_only = true]; +} diff --git a/protoc-gen-prost-validate/tests/proto/cases/numbers.proto b/protoc-gen-prost-validate/tests/proto/cases/numbers.proto new file mode 100644 index 0000000..ea6747b --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/numbers.proto @@ -0,0 +1,175 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; + +message FloatNone { float val = 1; } +message FloatConst { float val = 1 [(validate.rules).float.const = 1.23]; } +message FloatIn { float val = 1 [(validate.rules).float = {in: [4.56, 7.89]}]; } +message FloatNotIn { float val = 1 [(validate.rules).float = {not_in: [0]}]; } +message FloatLT { float val = 1 [(validate.rules).float.lt = 0]; } +message FloatLTE { float val = 1 [(validate.rules).float.lte = 64]; } +message FloatGT { float val = 1 [(validate.rules).float.gt = 16]; } +message FloatGTE { float val = 1 [(validate.rules).float.gte = 8]; } +message FloatGTLT { float val = 1 [(validate.rules).float = {gt: 0, lt: 10}]; } +message FloatExLTGT { float val = 1 [(validate.rules).float = {lt: 0, gt: 10}]; } +message FloatGTELTE { float val = 1 [(validate.rules).float = {gte: 128, lte: 256}]; } +message FloatExGTELTE { float val = 1 [(validate.rules).float = {lte: 128, gte: 256}]; } +message FloatIgnore { float val = 1 [(validate.rules).float = {gte: 128, lte: 256, ignore_empty: true}]; } + +message DoubleNone { double val = 1; } +message DoubleConst { double val = 1 [(validate.rules).double.const = 1.23]; } +message DoubleIn { double val = 1 [(validate.rules).double = {in: [4.56, 7.89]}]; } +message DoubleNotIn { double val = 1 [(validate.rules).double = {not_in: [0]}]; } +message DoubleLT { double val = 1 [(validate.rules).double.lt = 0]; } +message DoubleLTE { double val = 1 [(validate.rules).double.lte = 64]; } +message DoubleGT { double val = 1 [(validate.rules).double.gt = 16]; } +message DoubleGTE { double val = 1 [(validate.rules).double.gte = 8]; } +message DoubleGTLT { double val = 1 [(validate.rules).double = {gt: 0, lt: 10}]; } +message DoubleExLTGT { double val = 1 [(validate.rules).double = {lt: 0, gt: 10}]; } +message DoubleGTELTE { double val = 1 [(validate.rules).double = {gte: 128, lte: 256}]; } +message DoubleExGTELTE { double val = 1 [(validate.rules).double = {lte: 128, gte: 256}]; } +message DoubleIgnore { double val = 1 [(validate.rules).double = {lte: 128, gte: 256, ignore_empty: true}]; } + +message Int32None { int32 val = 1; } +message Int32Const { int32 val = 1 [(validate.rules).int32.const = 1]; } +message Int32In { int32 val = 1 [(validate.rules).int32 = {in: [2, 3]}]; } +message Int32NotIn { int32 val = 1 [(validate.rules).int32 = {not_in: [0]}]; } +message Int32LT { int32 val = 1 [(validate.rules).int32.lt = 0]; } +message Int32LTE { int32 val = 1 [(validate.rules).int32.lte = 64]; } +message Int32GT { int32 val = 1 [(validate.rules).int32.gt = 16]; } +message Int32GTE { int32 val = 1 [(validate.rules).int32.gte = 8]; } +message Int32GTLT { int32 val = 1 [(validate.rules).int32 = {gt: 0, lt: 10}]; } +message Int32ExLTGT { int32 val = 1 [(validate.rules).int32 = {lt: 0, gt: 10}]; } +message Int32GTELTE { int32 val = 1 [(validate.rules).int32 = {gte: 128, lte: 256}]; } +message Int32ExGTELTE { int32 val = 1 [(validate.rules).int32 = {lte: 128, gte: 256}]; } +message Int32Ignore { int32 val = 1 [(validate.rules).int32 = {lte: 128, gte: 256, ignore_empty: true}]; } + +message Int64None { int64 val = 1; } +message Int64Const { int64 val = 1 [(validate.rules).int64.const = 1]; } +message Int64In { int64 val = 1 [(validate.rules).int64 = {in: [2, 3]}]; } +message Int64NotIn { int64 val = 1 [(validate.rules).int64 = {not_in: [0]}]; } +message Int64LT { int64 val = 1 [(validate.rules).int64.lt = 0]; } +message Int64LTE { int64 val = 1 [(validate.rules).int64.lte = 64]; } +message Int64GT { int64 val = 1 [(validate.rules).int64.gt = 16]; } +message Int64GTE { int64 val = 1 [(validate.rules).int64.gte = 8]; } +message Int64GTLT { int64 val = 1 [(validate.rules).int64 = {gt: 0, lt: 10}]; } +message Int64ExLTGT { int64 val = 1 [(validate.rules).int64 = {lt: 0, gt: 10}]; } +message Int64GTELTE { int64 val = 1 [(validate.rules).int64 = {gte: 128, lte: 256}]; } +message Int64ExGTELTE { int64 val = 1 [(validate.rules).int64 = {lte: 128, gte: 256}]; } +message Int64Ignore { int64 val = 1 [(validate.rules).int64 = {lte: 128, gte: 256, ignore_empty: true}]; } + +message UInt32None { uint32 val = 1; } +message UInt32Const { uint32 val = 1 [(validate.rules).uint32.const = 1]; } +message UInt32In { uint32 val = 1 [(validate.rules).uint32 = {in: [2, 3]}]; } +message UInt32NotIn { uint32 val = 1 [(validate.rules).uint32 = {not_in: [0]}]; } +message UInt32LT { uint32 val = 1 [(validate.rules).uint32.lt = 5]; } +message UInt32LTE { uint32 val = 1 [(validate.rules).uint32.lte = 64]; } +message UInt32GT { uint32 val = 1 [(validate.rules).uint32.gt = 16]; } +message UInt32GTE { uint32 val = 1 [(validate.rules).uint32.gte = 8]; } +message UInt32GTLT { uint32 val = 1 [(validate.rules).uint32 = {gt: 5, lt: 10}]; } +message UInt32ExLTGT { uint32 val = 1 [(validate.rules).uint32 = {lt: 5, gt: 10}]; } +message UInt32GTELTE { uint32 val = 1 [(validate.rules).uint32 = {gte: 128, lte: 256}]; } +message UInt32ExGTELTE { uint32 val = 1 [(validate.rules).uint32 = {lte: 128, gte: 256}]; } +message UInt32Ignore { uint32 val = 1 [(validate.rules).uint32 = {lte: 128, gte: 256, ignore_empty: true}]; } + +message UInt64None { uint64 val = 1; } +message UInt64Const { uint64 val = 1 [(validate.rules).uint64.const = 1]; } +message UInt64In { uint64 val = 1 [(validate.rules).uint64 = {in: [2, 3]}]; } +message UInt64NotIn { uint64 val = 1 [(validate.rules).uint64 = {not_in: [0]}]; } +message UInt64LT { uint64 val = 1 [(validate.rules).uint64.lt = 5]; } +message UInt64LTE { uint64 val = 1 [(validate.rules).uint64.lte = 64]; } +message UInt64GT { uint64 val = 1 [(validate.rules).uint64.gt = 16]; } +message UInt64GTE { uint64 val = 1 [(validate.rules).uint64.gte = 8]; } +message UInt64GTLT { uint64 val = 1 [(validate.rules).uint64 = {gt: 5, lt: 10}]; } +message UInt64ExLTGT { uint64 val = 1 [(validate.rules).uint64 = {lt: 5, gt: 10}]; } +message UInt64GTELTE { uint64 val = 1 [(validate.rules).uint64 = {gte: 128, lte: 256}]; } +message UInt64ExGTELTE { uint64 val = 1 [(validate.rules).uint64 = {lte: 128, gte: 256}]; } +message UInt64Ignore { uint64 val = 1 [(validate.rules).uint64 = {lte: 128, gte: 256, ignore_empty: true}]; } + +message SInt32None { sint32 val = 1; } +message SInt32Const { sint32 val = 1 [(validate.rules).sint32.const = 1]; } +message SInt32In { sint32 val = 1 [(validate.rules).sint32 = {in: [2, 3]}]; } +message SInt32NotIn { sint32 val = 1 [(validate.rules).sint32 = {not_in: [0]}]; } +message SInt32LT { sint32 val = 1 [(validate.rules).sint32.lt = 0]; } +message SInt32LTE { sint32 val = 1 [(validate.rules).sint32.lte = 64]; } +message SInt32GT { sint32 val = 1 [(validate.rules).sint32.gt = 16]; } +message SInt32GTE { sint32 val = 1 [(validate.rules).sint32.gte = 8]; } +message SInt32GTLT { sint32 val = 1 [(validate.rules).sint32 = {gt: 0, lt: 10}]; } +message SInt32ExLTGT { sint32 val = 1 [(validate.rules).sint32 = {lt: 0, gt: 10}]; } +message SInt32GTELTE { sint32 val = 1 [(validate.rules).sint32 = {gte: 128, lte: 256}]; } +message SInt32ExGTELTE { sint32 val = 1 [(validate.rules).sint32 = {lte: 128, gte: 256}]; } +message SInt32Ignore { sint32 val = 1 [(validate.rules).sint32 = {lte: 128, gte: 256, ignore_empty: true}]; } + +message SInt64None { sint64 val = 1; } +message SInt64Const { sint64 val = 1 [(validate.rules).sint64.const = 1]; } +message SInt64In { sint64 val = 1 [(validate.rules).sint64 = {in: [2, 3]}]; } +message SInt64NotIn { sint64 val = 1 [(validate.rules).sint64 = {not_in: [0]}]; } +message SInt64LT { sint64 val = 1 [(validate.rules).sint64.lt = 0]; } +message SInt64LTE { sint64 val = 1 [(validate.rules).sint64.lte = 64]; } +message SInt64GT { sint64 val = 1 [(validate.rules).sint64.gt = 16]; } +message SInt64GTE { sint64 val = 1 [(validate.rules).sint64.gte = 8]; } +message SInt64GTLT { sint64 val = 1 [(validate.rules).sint64 = {gt: 0, lt: 10}]; } +message SInt64ExLTGT { sint64 val = 1 [(validate.rules).sint64 = {lt: 0, gt: 10}]; } +message SInt64GTELTE { sint64 val = 1 [(validate.rules).sint64 = {gte: 128, lte: 256}]; } +message SInt64ExGTELTE { sint64 val = 1 [(validate.rules).sint64 = {lte: 128, gte: 256}]; } +message SInt64Ignore { sint64 val = 1 [(validate.rules).sint64 = {lte: 128, gte: 256, ignore_empty: true}]; } + +message Fixed32None { fixed32 val = 1; } +message Fixed32Const { fixed32 val = 1 [(validate.rules).fixed32.const = 1]; } +message Fixed32In { fixed32 val = 1 [(validate.rules).fixed32 = {in: [2, 3]}]; } +message Fixed32NotIn { fixed32 val = 1 [(validate.rules).fixed32 = {not_in: [0]}]; } +message Fixed32LT { fixed32 val = 1 [(validate.rules).fixed32.lt = 5]; } +message Fixed32LTE { fixed32 val = 1 [(validate.rules).fixed32.lte = 64]; } +message Fixed32GT { fixed32 val = 1 [(validate.rules).fixed32.gt = 16]; } +message Fixed32GTE { fixed32 val = 1 [(validate.rules).fixed32.gte = 8]; } +message Fixed32GTLT { fixed32 val = 1 [(validate.rules).fixed32 = {gt: 5, lt: 10}]; } +message Fixed32ExLTGT { fixed32 val = 1 [(validate.rules).fixed32 = {lt: 5, gt: 10}]; } +message Fixed32GTELTE { fixed32 val = 1 [(validate.rules).fixed32 = {gte: 128, lte: 256}]; } +message Fixed32ExGTELTE { fixed32 val = 1 [(validate.rules).fixed32 = {lte: 128, gte: 256}]; } +message Fixed32Ignore { fixed32 val = 1 [(validate.rules).fixed32 = {lte: 128, gte: 256, ignore_empty: true}]; } + +message Fixed64None { fixed64 val = 1; } +message Fixed64Const { fixed64 val = 1 [(validate.rules).fixed64.const = 1]; } +message Fixed64In { fixed64 val = 1 [(validate.rules).fixed64 = {in: [2, 3]}]; } +message Fixed64NotIn { fixed64 val = 1 [(validate.rules).fixed64 = {not_in: [0]}]; } +message Fixed64LT { fixed64 val = 1 [(validate.rules).fixed64.lt = 5]; } +message Fixed64LTE { fixed64 val = 1 [(validate.rules).fixed64.lte = 64]; } +message Fixed64GT { fixed64 val = 1 [(validate.rules).fixed64.gt = 16]; } +message Fixed64GTE { fixed64 val = 1 [(validate.rules).fixed64.gte = 8]; } +message Fixed64GTLT { fixed64 val = 1 [(validate.rules).fixed64 = {gt: 5, lt: 10}]; } +message Fixed64ExLTGT { fixed64 val = 1 [(validate.rules).fixed64 = {lt: 5, gt: 10}]; } +message Fixed64GTELTE { fixed64 val = 1 [(validate.rules).fixed64 = {gte: 128, lte: 256}]; } +message Fixed64ExGTELTE { fixed64 val = 1 [(validate.rules).fixed64 = {lte: 128, gte: 256}]; } +message Fixed64Ignore { fixed64 val = 1 [(validate.rules).fixed64 = {lte: 128, gte: 256, ignore_empty: true}]; } + +message SFixed32None { sfixed32 val = 1; } +message SFixed32Const { sfixed32 val = 1 [(validate.rules).sfixed32.const = 1]; } +message SFixed32In { sfixed32 val = 1 [(validate.rules).sfixed32 = {in: [2, 3]}]; } +message SFixed32NotIn { sfixed32 val = 1 [(validate.rules).sfixed32 = {not_in: [0]}]; } +message SFixed32LT { sfixed32 val = 1 [(validate.rules).sfixed32.lt = 0]; } +message SFixed32LTE { sfixed32 val = 1 [(validate.rules).sfixed32.lte = 64]; } +message SFixed32GT { sfixed32 val = 1 [(validate.rules).sfixed32.gt = 16]; } +message SFixed32GTE { sfixed32 val = 1 [(validate.rules).sfixed32.gte = 8]; } +message SFixed32GTLT { sfixed32 val = 1 [(validate.rules).sfixed32 = {gt: 0, lt: 10}]; } +message SFixed32ExLTGT { sfixed32 val = 1 [(validate.rules).sfixed32 = {lt: 0, gt: 10}]; } +message SFixed32GTELTE { sfixed32 val = 1 [(validate.rules).sfixed32 = {gte: 128, lte: 256}]; } +message SFixed32ExGTELTE { sfixed32 val = 1 [(validate.rules).sfixed32 = {lte: 128, gte: 256}]; } +message SFixed32Ignore { sfixed32 val = 1 [(validate.rules).sfixed32 = {lte: 128, gte: 256, ignore_empty: true}]; } + +message SFixed64None { sfixed64 val = 1; } +message SFixed64Const { sfixed64 val = 1 [(validate.rules).sfixed64.const = 1]; } +message SFixed64In { sfixed64 val = 1 [(validate.rules).sfixed64 = {in: [2, 3]}]; } +message SFixed64NotIn { sfixed64 val = 1 [(validate.rules).sfixed64 = {not_in: [0]}]; } +message SFixed64LT { sfixed64 val = 1 [(validate.rules).sfixed64.lt = 0]; } +message SFixed64LTE { sfixed64 val = 1 [(validate.rules).sfixed64.lte = 64]; } +message SFixed64GT { sfixed64 val = 1 [(validate.rules).sfixed64.gt = 16]; } +message SFixed64GTE { sfixed64 val = 1 [(validate.rules).sfixed64.gte = 8]; } +message SFixed64GTLT { sfixed64 val = 1 [(validate.rules).sfixed64 = {gt: 0, lt: 10}]; } +message SFixed64ExLTGT { sfixed64 val = 1 [(validate.rules).sfixed64 = {lt: 0, gt: 10}]; } +message SFixed64GTELTE { sfixed64 val = 1 [(validate.rules).sfixed64 = {gte: 128, lte: 256}]; } +message SFixed64ExGTELTE { sfixed64 val = 1 [(validate.rules).sfixed64 = {lte: 128, gte: 256}]; } +message SFixed64Ignore { sfixed64 val = 1 [(validate.rules).sfixed64 = {lte: 128, gte: 256, ignore_empty: true}]; } + +message Int64LTEOptional { optional int64 val = 1 [(validate.rules).int64.lte = 64]; } diff --git a/protoc-gen-prost-validate/tests/proto/cases/oneofs.proto b/protoc-gen-prost-validate/tests/proto/cases/oneofs.proto new file mode 100644 index 0000000..f325715 --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/oneofs.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; + +message TestOneOfMsg { + bool val = 1 [(validate.rules).bool.const = true]; +} + +message OneOfNone { + oneof o { + string x = 1; + int32 y = 2; + } +} + +message OneOf { + oneof o { + string x = 1 [(validate.rules).string.prefix = "foo"]; + int32 y = 2 [(validate.rules).int32.gt = 0]; + TestOneOfMsg z = 3; + } +} + +message OneOfRequired { + oneof o { + option (validate.required) = true; + + string x = 1; + int32 y = 2; + int32 name_with_underscores = 3; + int32 under_and_1_number = 4; + } +} + +message OneOfIgnoreEmpty { + oneof o { + string x = 1 [(validate.rules).string = {ignore_empty: true, min_len: 3, max_len: 5}]; + bytes y = 2 [(validate.rules).bytes = {ignore_empty: true, min_len: 3, max_len: 5}]; + int32 z = 3 [(validate.rules).int32 = {lte: 128, gte: 256, ignore_empty: true}]; + } +} diff --git a/protoc-gen-prost-validate/tests/proto/cases/repeated.proto b/protoc-gen-prost-validate/tests/proto/cases/repeated.proto new file mode 100644 index 0000000..c73bfee --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/repeated.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "other_package/embed.proto"; + +import "validate/validate.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/any.proto"; + +message Embed { int64 val = 1 [(validate.rules).int64.gt = 0]; } +enum AnEnum { + X = 0; + Y = 1; +} + +message RepeatedNone { repeated int64 val = 1; } +message RepeatedEmbedNone { repeated Embed val = 1; } +message RepeatedEmbedCrossPackageNone { repeated tests.harness.cases.other_package.Embed val = 1; } +message RepeatedMin { repeated Embed val = 1 [(validate.rules).repeated.min_items = 2]; } +message RepeatedMax { repeated double val = 1 [(validate.rules).repeated.max_items = 3]; } +message RepeatedMinMax { repeated sfixed32 val = 1 [(validate.rules).repeated = {min_items: 2, max_items: 4}]; } +message RepeatedExact { repeated uint32 val = 1 [(validate.rules).repeated = {min_items: 3, max_items: 3}]; } +message RepeatedUnique { repeated string val = 1 [(validate.rules).repeated.unique = true]; } +message RepeatedItemRule { repeated float val = 1 [(validate.rules).repeated.items.float.gt = 0]; } +message RepeatedItemPattern { repeated string val = 1 [(validate.rules).repeated.items.string.pattern = "(?i)^[a-z0-9]+$"]; } +message RepeatedEmbedSkip { repeated Embed val = 1 [(validate.rules).repeated.items.message.skip = true]; } +message RepeatedItemIn { repeated string val = 1 [(validate.rules).repeated.items.string = {in: ["foo", "bar"]}]; } +message RepeatedItemNotIn { repeated string val = 1 [(validate.rules).repeated.items.string = {not_in: ["foo", "bar"]}]; } +message RepeatedEnumIn { repeated AnEnum val = 1 [(validate.rules).repeated.items.enum = {in: [0]}]; } +message RepeatedEnumNotIn { repeated AnEnum val = 1 [(validate.rules).repeated.items.enum = {not_in: [0]}]; } +message RepeatedEmbeddedEnumIn { repeated AnotherInEnum val = 1 [(validate.rules).repeated.items.enum = {in: [0]}]; enum AnotherInEnum {A = 0; B = 1; }} +message RepeatedEmbeddedEnumNotIn { repeated AnotherNotInEnum val = 1 [(validate.rules).repeated.items.enum = {not_in: [0]}]; enum AnotherNotInEnum {A = 0; B = 1; }} +message RepeatedAnyIn { repeated google.protobuf.Any val = 1 [(validate.rules).repeated.items.any = {in: ["type.googleapis.com/google.protobuf.Duration"]}]; } +message RepeatedAnyNotIn { repeated google.protobuf.Any val = 1 [(validate.rules).repeated.items.any = {not_in: ["type.googleapis.com/google.protobuf.Timestamp"]}]; } +message RepeatedMinAndItemLen { repeated string val = 1 [(validate.rules).repeated = { items { string { len: 3 } }, min_items: 1 }]; } +message RepeatedMinAndMaxItemLen { repeated string val = 1 [(validate.rules).repeated.min_items = 1, (validate.rules).repeated.max_items = 3]; } +message RepeatedDuration { repeated google.protobuf.Duration val = 1 [(validate.rules).repeated = { items { duration { gte { nanos: 1000000}}}}]; } +message RepeatedExactIgnore { repeated uint32 val = 1 [(validate.rules).repeated = {min_items: 3, max_items: 3, ignore_empty: true}]; } diff --git a/protoc-gen-prost-validate/tests/proto/cases/strings.proto b/protoc-gen-prost-validate/tests/proto/cases/strings.proto new file mode 100644 index 0000000..99a0e9e --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/strings.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; + +message StringNone { string val = 1; } +message StringConst { string val = 1 [(validate.rules).string.const = "foo"]; } +message StringIn { string val = 1 [(validate.rules).string = {in: ["bar", "baz"]}]; } +message StringNotIn { string val = 1 [(validate.rules).string = {not_in: ["fizz", "buzz"]}]; } +message StringLen { string val = 1 [(validate.rules).string.len = 3]; } +message StringMinLen { string val = 1 [(validate.rules).string.min_len = 3]; } +message StringMaxLen { string val = 1 [(validate.rules).string.max_len = 5]; } +message StringMinMaxLen { string val = 1 [(validate.rules).string = {min_len: 3, max_len: 5}]; } +message StringEqualMinMaxLen { string val = 1 [(validate.rules).string = {min_len: 5, max_len: 5}]; } +message StringLenBytes { string val = 1 [(validate.rules).string.len_bytes = 4]; } +message StringMinBytes { string val = 1 [(validate.rules).string.min_bytes = 4]; } +message StringMaxBytes { string val = 1 [(validate.rules).string.max_bytes = 8]; } +message StringMinMaxBytes { string val = 1 [(validate.rules).string = {min_bytes: 4, max_bytes: 8}]; } +message StringEqualMinMaxBytes { string val = 1 [(validate.rules).string = {min_bytes: 4, max_bytes: 8}]; } +message StringPattern { string val = 1 [(validate.rules).string.pattern = "(?i)^[a-z0-9]+$"]; } +message StringPatternEscapes { string val = 1 [(validate.rules).string.pattern = "\\* \\\\ \\w"]; } +message StringPrefix { string val = 1 [(validate.rules).string.prefix = "foo"]; } +message StringContains { string val = 1 [(validate.rules).string.contains = "bar"]; } +message StringNotContains { string val = 1 [(validate.rules).string.not_contains = "bar"]; } +message StringSuffix { string val = 1 [(validate.rules).string.suffix = "baz"]; } +message StringEmail { string val = 1 [(validate.rules).string.email = true]; } +message StringAddress { string val = 1 [(validate.rules).string.address = true]; } +message StringHostname { string val = 1 [(validate.rules).string.hostname = true]; } +message StringIP { string val = 1 [(validate.rules).string.ip = true]; } +message StringIPv4 { string val = 1 [(validate.rules).string.ipv4 = true]; } +message StringIPv6 { string val = 1 [(validate.rules).string.ipv6 = true]; } +message StringURI { string val = 1 [(validate.rules).string.uri = true]; } +message StringURIRef { string val = 1 [(validate.rules).string.uri_ref = true]; } +message StringUUID { string val = 1 [(validate.rules).string.uuid = true]; } +message StringHttpHeaderName { string val = 1 [(validate.rules).string.well_known_regex = HTTP_HEADER_NAME]; } +message StringHttpHeaderValue { string val = 1 [(validate.rules).string.well_known_regex = HTTP_HEADER_VALUE]; } +message StringValidHeader { string val = 1 [(validate.rules).string = {well_known_regex: HTTP_HEADER_VALUE, strict: false}]; } +message StringUUIDIgnore { string val = 1 [(validate.rules).string = {uuid: true, ignore_empty: true}]; } + +message StringInOneOf { + oneof foo { + string bar = 1 [(validate.rules).string = {in: "a" in: "b"}]; + } + } diff --git a/protoc-gen-prost-validate/tests/proto/cases/wkt_any.proto b/protoc-gen-prost-validate/tests/proto/cases/wkt_any.proto new file mode 100644 index 0000000..c54f724 --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/wkt_any.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; +import "google/protobuf/any.proto"; + +message AnyNone { google.protobuf.Any val = 1; } +message AnyRequired { google.protobuf.Any val = 1 [(validate.rules).any.required = true]; } +message AnyIn { google.protobuf.Any val = 1 [(validate.rules).any = {in: ["type.googleapis.com/google.protobuf.Duration"]}];} +message AnyNotIn { google.protobuf.Any val = 1 [(validate.rules).any = {not_in: ["type.googleapis.com/google.protobuf.Timestamp"]}];} diff --git a/protoc-gen-prost-validate/tests/proto/cases/wkt_duration.proto b/protoc-gen-prost-validate/tests/proto/cases/wkt_duration.proto new file mode 100644 index 0000000..09d028c --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/wkt_duration.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; + +import "validate/validate.proto"; +import "google/protobuf/duration.proto"; + +message DurationNone { google.protobuf.Duration val = 1; } + +message DurationRequired { google.protobuf.Duration val = 1 [(validate.rules).duration.required = true]; } +// TODO(htuch): Add a very large duration, e.g. {seconds: 315576000000}, once +// #34 is resolved. +message DurationConst { google.protobuf.Duration val = 1 [(validate.rules).duration.const = {seconds: 3}]; } + +message DurationIn { google.protobuf.Duration val = 1 [(validate.rules).duration = {in: [{seconds:1}, {nanos:1000}]}]; } +message DurationNotIn { google.protobuf.Duration val = 1 [(validate.rules).duration = {not_in: [{}]}]; } + +message DurationLT { google.protobuf.Duration val = 1 [(validate.rules).duration.lt = {}]; } +message DurationLTE { google.protobuf.Duration val = 1 [(validate.rules).duration.lte = {seconds: 1}]; } +message DurationGT { google.protobuf.Duration val = 1 [(validate.rules).duration.gt = {nanos: 1000}]; } +message DurationGTE { google.protobuf.Duration val = 1 [(validate.rules).duration.gte = {nanos: 1000000}]; } +message DurationGTLT { google.protobuf.Duration val = 1 [(validate.rules).duration = {gt: {}, lt: {seconds: 1}}]; } +message DurationExLTGT { google.protobuf.Duration val = 1 [(validate.rules).duration = {lt: {}, gt: {seconds: 1}}]; } +message DurationGTELTE { google.protobuf.Duration val = 1 [(validate.rules).duration = {gte: {seconds: 60}, lte: {seconds: 3600}}]; } +message DurationExGTELTE { google.protobuf.Duration val = 1 [(validate.rules).duration = {lte: {seconds: 60}, gte: {seconds: 3600}}]; } + +// Regression for earlier bug where missing Duration field would short circuit +// evaluation in C++. +message DurationFieldWithOtherFields { + google.protobuf.Duration duration_val = 1 [(validate.rules).duration.lte = {seconds: 1}]; + int32 int_val = 2 [(validate.rules).int32.gt = 16]; +} diff --git a/protoc-gen-prost-validate/tests/proto/cases/wkt_nested.proto b/protoc-gen-prost-validate/tests/proto/cases/wkt_nested.proto new file mode 100644 index 0000000..ecf08ab --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/wkt_nested.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; + +import "validate/validate.proto"; + +message WktLevelOne { + message WktLevelTwo { + message WktLevelThree { + string uuid = 1 [(validate.rules).string.uuid = true]; + } + + WktLevelThree three = 1 [(validate.rules).message.required = true]; + } + + WktLevelTwo two = 1 [(validate.rules).message.required = true]; +} diff --git a/protoc-gen-prost-validate/tests/proto/cases/wkt_timestamp.proto b/protoc-gen-prost-validate/tests/proto/cases/wkt_timestamp.proto new file mode 100644 index 0000000..64c694e --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/wkt_timestamp.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; +import "google/protobuf/timestamp.proto"; + +message TimestampNone { google.protobuf.Timestamp val = 1; } +message TimestampRequired { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp.required = true]; } +message TimestampConst { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp.const = {seconds: 3}]; } + +message TimestampLT { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp.lt = {}]; } +message TimestampLTE { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp.lte = {seconds: 1}]; } +message TimestampGT { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp.gt = {nanos: 1000}]; } +message TimestampGTE { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp.gte = {nanos: 1000000}]; } +message TimestampGTLT { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp = {gt: {}, lt: {seconds: 1}}]; } +message TimestampExLTGT { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp = {lt: {}, gt: {seconds: 1}}]; } +message TimestampGTELTE { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp = {gte: {seconds: 60}, lte: {seconds: 3600}}]; } +message TimestampExGTELTE { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp = {lte: {seconds: 60}, gte: {seconds: 3600}}]; } + +message TimestampLTNow { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp.lt_now = true]; } +message TimestampGTNow { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp.gt_now = true]; } + +message TimestampWithin { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp.within.seconds = 3600]; } + +message TimestampLTNowWithin { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp = {lt_now: true, within: {seconds: 3600}}]; } +message TimestampGTNowWithin { google.protobuf.Timestamp val = 1 [(validate.rules).timestamp = {gt_now: true, within: {seconds: 3600}}]; } diff --git a/protoc-gen-prost-validate/tests/proto/cases/wkt_wrappers.proto b/protoc-gen-prost-validate/tests/proto/cases/wkt_wrappers.proto new file mode 100644 index 0000000..3b73e1a --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/cases/wkt_wrappers.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; +import "google/protobuf/wrappers.proto"; + +message WrapperNone { google.protobuf.Int32Value val = 1; } + +message WrapperFloat { google.protobuf.FloatValue val = 1 [(validate.rules).float.gt = 0]; } +message WrapperDouble { google.protobuf.DoubleValue val = 1 [(validate.rules).double.gt = 0]; } +message WrapperInt64 { google.protobuf.Int64Value val = 1 [(validate.rules).int64.gt = 0]; } +message WrapperInt32 { google.protobuf.Int32Value val = 1 [(validate.rules).int32.gt = 0]; } +message WrapperUInt64 { google.protobuf.UInt64Value val = 1 [(validate.rules).uint64.gt = 0]; } +message WrapperUInt32 { google.protobuf.UInt32Value val = 1 [(validate.rules).uint32.gt = 0]; } +message WrapperBool { google.protobuf.BoolValue val = 1 [(validate.rules).bool.const = true]; } +message WrapperString { google.protobuf.StringValue val = 1 [(validate.rules).string.suffix = "bar"]; } +message WrapperBytes { google.protobuf.BytesValue val = 1 [(validate.rules).bytes.min_len = 3]; } +message WrapperRequiredString { google.protobuf.StringValue val = 1 [(validate.rules).string.const = "bar", (validate.rules).message.required = true]; } +message WrapperRequiredEmptyString { google.protobuf.StringValue val = 1 [(validate.rules).string.const = "", (validate.rules).message.required = true]; } +message WrapperOptionalUuidString { google.protobuf.StringValue val = 1 [(validate.rules).string.uuid = true, (validate.rules).message.required = false]; } +message WrapperRequiredFloat { google.protobuf.FloatValue val = 1 [(validate.rules).float.gt = 0, (validate.rules).message.required = true]; } diff --git a/protoc-gen-prost-validate/tests/proto/other_package/embed.proto b/protoc-gen-prost-validate/tests/proto/other_package/embed.proto new file mode 100644 index 0000000..8e19faa --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/other_package/embed.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package tests.harness.cases.other_package; +option go_package = "tests/proto/cases/other_package;other_package"; + +import "validate/validate.proto"; + +// Validate message embedding across packages. +message Embed { + message DoubleEmbed { + enum DoubleEnumerated { VALUE = 0; } + } + + int64 val = 1 [(validate.rules).int64.gt = 0]; + + enum Enumerated { VALUE = 0; } + + enum FooNumber { + ZERO = 0; + ONE = 1; + TWO = 2; + } +} diff --git a/protoc-gen-prost-validate/tests/proto/sort/sort.proto b/protoc-gen-prost-validate/tests/proto/sort/sort.proto new file mode 100644 index 0000000..caa91bb --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/sort/sort.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package tests.harness.cases.sort; +option go_package = "tests/proto/cases/sort;sort"; + +enum Direction { + UNKNOWN_DIRECTION = 0; + ASC = 1; + DESC = 2; +} diff --git a/protoc-gen-prost-validate/tests/proto/subdirectory/in_subdirectory.proto b/protoc-gen-prost-validate/tests/proto/subdirectory/in_subdirectory.proto new file mode 100644 index 0000000..9180d33 --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/subdirectory/in_subdirectory.proto @@ -0,0 +1,6 @@ +syntax = "proto3"; + +package tests.harness.cases; +option go_package = "tests/proto/cases;cases"; +import "validate/validate.proto"; + diff --git a/protoc-gen-prost-validate/tests/proto/yet_another_package/embed.proto b/protoc-gen-prost-validate/tests/proto/yet_another_package/embed.proto new file mode 100644 index 0000000..54570ad --- /dev/null +++ b/protoc-gen-prost-validate/tests/proto/yet_another_package/embed.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package tests.harness.cases.yet_another_package; +option go_package = "tests/proto/cases/yet_another_package;yet_another_package"; + +import "validate/validate.proto"; + +// Validate message embedding across packages. +message Embed { + int64 val = 1 [(validate.rules).int64.gt = 0]; + + enum Enumerated { VALUE = 0; } + + enum BarNumber { + ZERO = 0; + ONE = 1; + TWO = 2; + } +} diff --git a/protoc-gen-prost/src/lib.rs b/protoc-gen-prost/src/lib.rs index 2c58af0..b90dad3 100644 --- a/protoc-gen-prost/src/lib.rs +++ b/protoc-gen-prost/src/lib.rs @@ -231,37 +231,37 @@ impl ModuleRequest { /// /// [`Generator`]: crate::Generator #[derive(Debug, Default)] -struct Parameters { +pub struct Parameters { /// Prost parameters, used to generate [`prost_build::Config`] - prost: ProstParameters, + pub prost: ProstParameters, /// Whether a file descriptor set has been requested in each module - file_descriptor_set: bool, + pub file_descriptor_set: bool, } /// Parameters used to configure the underlying Prost generator #[derive(Debug, Default)] -struct ProstParameters { - btree_map: Vec, - bytes: Vec, - boxed: Vec, - disable_comments: Vec, - skip_debug: Vec, - default_package_filename: Option, - extern_path: Vec<(String, String)>, - type_attribute: Vec<(String, String)>, - field_attribute: Vec<(String, String)>, - enum_attribute: Vec<(String, String)>, - message_attribute: Vec<(String, String)>, - compile_well_known_types: bool, - retain_enum_prefix: bool, - enable_type_names: bool, - flat_output_dir: bool, +pub struct ProstParameters { + pub btree_map: Vec, + pub bytes: Vec, + pub boxed: Vec, + pub disable_comments: Vec, + pub skip_debug: Vec, + pub default_package_filename: Option, + pub extern_path: Vec<(String, String)>, + pub type_attribute: Vec<(String, String)>, + pub field_attribute: Vec<(String, String)>, + pub enum_attribute: Vec<(String, String)>, + pub message_attribute: Vec<(String, String)>, + pub compile_well_known_types: bool, + pub retain_enum_prefix: bool, + pub enable_type_names: bool, + pub flat_output_dir: bool, } impl ProstParameters { /// Builds a [`prost_build::Config`] from the parameters - fn to_prost_config(&self) -> prost_build::Config { + pub fn to_prost_config(&self) -> prost_build::Config { let mut config = prost_build::Config::new(); config.btree_map(self.btree_map.iter()); config.bytes(self.bytes.iter()); @@ -304,11 +304,11 @@ impl ProstParameters { config } - fn default_package_filename(&self) -> Option<&str> { + pub fn default_package_filename(&self) -> Option<&str> { self.default_package_filename.as_deref() } - fn try_handle_parameter<'a>(&mut self, param: Param<'a>) -> std::result::Result<(), Param<'a>> { + pub fn try_handle_parameter<'a>(&mut self, param: Param<'a>) -> std::result::Result<(), Param<'a>> { match param { Param::Value { param: "btree_map",