{"id":28501481,"url":"https://github.com/bufbuild/protovalidate-cc","last_synced_at":"2025-07-05T01:31:45.732Z","repository":{"id":175029750,"uuid":"644634806","full_name":"bufbuild/protovalidate-cc","owner":"bufbuild","description":"Protocol Buffer Validation for C++.","archived":false,"fork":false,"pushed_at":"2025-06-12T21:11:54.000Z","size":603,"stargazers_count":19,"open_issues_count":4,"forks_count":5,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-06-12T22:25:01.150Z","etag":null,"topics":["cc","cel","common-expression-language","protobuf","protocol-buffers"],"latest_commit_sha":null,"homepage":"https://buf.build/bufbuild/protovalidate","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bufbuild.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-24T00:04:22.000Z","updated_at":"2025-06-12T15:51:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"94ab3f3b-6c19-4152-a231-e45d0b988b91","html_url":"https://github.com/bufbuild/protovalidate-cc","commit_stats":null,"previous_names":["bufbuild/protovalidate-cc"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/bufbuild/protovalidate-cc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufbuild%2Fprotovalidate-cc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufbuild%2Fprotovalidate-cc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufbuild%2Fprotovalidate-cc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufbuild%2Fprotovalidate-cc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bufbuild","download_url":"https://codeload.github.com/bufbuild/protovalidate-cc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bufbuild%2Fprotovalidate-cc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260748670,"owners_count":23056603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cc","cel","common-expression-language","protobuf","protocol-buffers"],"created_at":"2025-06-08T16:06:51.521Z","updated_at":"2025-07-05T01:31:45.726Z","avatar_url":"https://github.com/bufbuild.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![The Buf logo](.github/buf-logo.svg)][buf]\n\n# protovalidate-cc\n\n[![CI](https://github.com/bufbuild/protovalidate-cc/actions/workflows/ci.yaml/badge.svg)](https://github.com/bufbuild/protovalidate-cc/actions/workflows/ci.yaml)\n[![Conformance](https://github.com/bufbuild/protovalidate-cc/actions/workflows/conformance.yaml/badge.svg)](https://github.com/bufbuild/protovalidate-cc/actions/workflows/conformance.yaml)\n[![BSR](https://img.shields.io/badge/BSR-Module-0C65EC)][buf-mod]\n\n[Protovalidate][protovalidate] is the semantic validation library for Protobuf. It provides standard annotations to validate common rules on messages and fields, as well as the ability to use [CEL][cel] to write custom rules. It's the next generation of [protoc-gen-validate][protoc-gen-validate].\n\nWith Protovalidate, you can annotate your Protobuf messages with both standard and custom validation rules:\n\n```protobuf\nsyntax = \"proto3\";\n\npackage acme.user.v1;\n\nimport \"buf/validate/validate.proto\";\n\nmessage User {\n  string id = 1 [(buf.validate.field).string.uuid = true];\n  uint32 age = 2 [(buf.validate.field).uint32.lte = 150]; // We can only hope.\n  string email = 3 [(buf.validate.field).string.email = true];\n  string first_name = 4 [(buf.validate.field).string.max_len = 64];\n  string last_name = 5 [(buf.validate.field).string.max_len = 64];\n\n  option (buf.validate.message).cel = {\n    id: \"first_name_requires_last_name\"\n    message: \"last_name must be present if first_name is present\"\n    expression: \"!has(this.first_name) || has(this.last_name)\"\n  };\n}\n```\n\nOnce you've added `protovalidate-cc` to your project, validation is idiomatic C++:\n\n```c++\nstd::unique_ptr\u003cbuf::validate::ValidatorFactory\u003e factory =\n  buf::validate::ValidatorFactory::New().value();\ngoogle::protobuf::Arena arena;\nbuf::validate::Validator validator = factory-\u003eNewValidator(\u0026arena);\nbuf::validate::Violations results = validator.Validate(moneyTransfer).value();\nif (results.violations_size() \u003e 0) {\n    // Handle failure\n}\n```\n\n## Installation\n\n### Building from source\n\nTo install `protovalidate-cc`, clone the repository and build the project:\n\n```shell\ngit clone https://github.com/bufbuild/protovalidate-cc.git\ncd protovalidate-cc\nmake build\n```\n\nRemember to always check for the latest version of `protovalidate-cc` on the project's [GitHub releases page](https://github.com/bufbuild/protovalidate-cc/releases) to ensure you're using the most up-to-date version.\n\n### Bazel external repository\n\n#### Workspace\n\nTo use `protovalidate-cc` as an external Bazel repository, add the following to the `WORKSPACE` file:\n\n```bzl\nload(\"@bazel_tools//tools/build_defs/repo:http.bzl\", \"http_archive\")\n\nhttp_archive(\n    name = \"com_github_bufbuild_protovalidate_cc\",\n    sha256 = ...,\n    strip_prefix = \"protovalidate-cc-{version}\",\n    urls = [\n        \"https://github.com/bufbuild/protovalidate-cc/releases/download/v{version}/protovalidate-cc-{version}.tar.gz\",\n    ],\n)\n\nload(\"@com_github_bufbuild_protovalidate_cc//bazel:deps.bzl\", \"protovalidate_cc_dependencies\")\n\nprotovalidate_cc_dependencies()\n```\n\nThen add a dependency to a `cc_library` or `cc_binary` target:\n\n```bzl\ncc_library(\n    ...\n    deps = [\n        \"@com_github_bufbuild_protovalidate_cc//buf/validate:validator\",\n        ...\n    ]\n)\n```\n\n#### Bzlmod\n\nTo use `protovalidate-cc` as an external dependency for bzlmod, add the following to the `MODULE.bazel`:\n\n```bzl\nmodule(\n    name = \"my-module\",\n    version = \"1.0\",\n)\n\nbazel_dep(name = \"cel-cpp\", repo_name = \"com_google_cel_cpp\", version=\"0.11.0\")\nbazel_dep(name = \"protovalidate-cc\", version = \"1.0.0-rc.2\")\n```\n\nAnd the following to your `BUILD.bazel`:\n\n```bzl\n\ncc_binary(\n   ...\n   deps = [ ..., \"@protovalidate-cc//buf/validate:validator\", ...]\n   ...\n)\n```\n\n## Documentation\n\nComprehensive documentation for Protovalidate is available in [Buf's documentation library][protovalidate].\n\nHighlights for C++ developers include:\n\n* The [developer quickstart][quickstart]\n* A [migration guide for protoc-gen-validate][migration-guide] users\n\n## Additional languages and repositories\n\nProtovalidate isn't just for C++! You might be interested in sibling repositories for other languages:\n\n- [`protovalidate-go`][pv-go] (Go)\n- [`protovalidate-java`][pv-java] (Java)\n- [`protovalidate-python`][pv-python] (Python)\n- [`protovalidate-es`][pv-es] (TypeScript and JavaScript)\n\nAdditionally, [protovalidate's core repository](https://github.com/bufbuild/protovalidate) provides:\n\n- [Protovalidate's Protobuf API][validate-proto]\n- [Conformance testing utilities][conformance] for acceptance testing of `protovalidate` implementations\n\n## Contributing\n\nWe genuinely appreciate any help! If you'd like to contribute, check out these resources:\n\n- [Contributing Guidelines][contributing]: Guidelines to make your contribution process straightforward and meaningful\n- [Conformance testing utilities](https://github.com/bufbuild/protovalidate/tree/main/docs/conformance.md): Utilities providing acceptance testing of `protovalidate` implementations\n\n## Legal\n\nOffered under the [Apache 2 license][license].\n\n[buf]: https://buf.build\n[cel]: https://cel.dev\n\n[pv-go]: https://github.com/bufbuild/protovalidate-go\n[pv-java]: https://github.com/bufbuild/protovalidate-java\n[pv-python]: https://github.com/bufbuild/protovalidate-python\n[pv-cc]: https://github.com/bufbuild/protovalidate-cc\n[pv-es]: https://github.com/bufbuild/protovalidate-es\n\n[buf-mod]: https://buf.build/bufbuild/protovalidate\n[license]: LICENSE\n[contributing]: .github/CONTRIBUTING.md\n\n[protoc-gen-validate]: https://github.com/bufbuild/protoc-gen-validate\n\n[protovalidate]: https://buf.build/docs/protovalidate/\n[quickstart]: https://buf.build/docs/protovalidate/quickstart/\n[connect-go]: https://buf.build/docs/protovalidate/quickstart/connect-go/\n[grpc-go]: https://buf.build/docs/protovalidate/quickstart/grpc-go/\n[grpc-java]: https://buf.build/docs/protovalidate/quickstart/grpc-java/\n[grpc-python]: https://buf.build/docs/protovalidate/quickstart/grpc-python/\n[migration-guide]: https://buf.build/docs/migration-guides/migrate-from-protoc-gen-validate/\n[pkg-go]: https://pkg.go.dev/github.com/bufbuild/protovalidate-go\n\n[validate-proto]: https://buf.build/bufbuild/protovalidate/docs/main:buf.validate\n[conformance]: https://github.com/bufbuild/protovalidate/blob/main/docs/conformance.md\n[examples]: https://github.com/bufbuild/protovalidate/tree/main/examples\n[migrate]: https://buf.build/docs/migration-guides/migrate-from-protoc-gen-validate/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufbuild%2Fprotovalidate-cc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbufbuild%2Fprotovalidate-cc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbufbuild%2Fprotovalidate-cc/lists"}