{"id":28921574,"url":"https://github.com/fabriziosestito/protoc-gen-validate","last_synced_at":"2025-10-05T00:00:12.362Z","repository":{"id":62480522,"uuid":"548296515","full_name":"fabriziosestito/protoc-gen-validate","owner":"fabriziosestito","description":"Elixir implementation of https://github.com/envoyproxy/protoc-gen-validate","archived":false,"fork":false,"pushed_at":"2022-11-04T13:05:57.000Z","size":146,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-23T15:52:55.858Z","etag":null,"topics":["elixir","hacktoberfest","protobuf","protoc"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabriziosestito.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-09T09:24:00.000Z","updated_at":"2022-10-10T12:07:27.000Z","dependencies_parsed_at":"2022-11-02T08:00:31.181Z","dependency_job_id":null,"html_url":"https://github.com/fabriziosestito/protoc-gen-validate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fabriziosestito/protoc-gen-validate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabriziosestito%2Fprotoc-gen-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabriziosestito%2Fprotoc-gen-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabriziosestito%2Fprotoc-gen-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabriziosestito%2Fprotoc-gen-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabriziosestito","download_url":"https://codeload.github.com/fabriziosestito/protoc-gen-validate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabriziosestito%2Fprotoc-gen-validate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278391180,"owners_count":25978945,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["elixir","hacktoberfest","protobuf","protoc"],"created_at":"2025-06-22T07:07:07.385Z","updated_at":"2025-10-05T00:00:12.344Z","avatar_url":"https://github.com/fabriziosestito.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ProtoValidator\n\nBased on: https://github.com/elixir-protobuf/protoc-gen-validate\n\nElixir implementation of https://github.com/envoyproxy/protoc-gen-validate\n\n## Installation\n\n```elixir\ndef deps do\n  [\n    {:proto_validator, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Usage\n\nDevelopers import the ProtoValidator and annotate the messages and fields in their proto files with constraint rules:\n\n```Elixir\npackage examplepb\n\nmessage User {\n  uint64 id    = 1 [(validate.rules) = {\n    uint64: {gt: 0, lt: 90},\n    message: {required: true}\n  }];\n\n  string email = 2 [(validate.rules).message.required = true];\n\n  GENDER gender = 3;\n\n  message Phone {\n    string phone_number = 1 [(validate.rules) = {\n      uint64: {gt: 1000, lt: 2000},\n      message: {required: true}\n    }];\n  }\n\n  repeated Phone phones = 4 [(validate.rules).repeated.min_items = 1];\n\n  repeated uint64 following_ids = 5 [(validate.rules).repeated = {\n    min_items: 0,\n    unique: true,\n    items: {uint64: {gt: 0, lt: 90}}\n  }];\n}\n```\n\nThen ProtoValidator will generate the validator modules for messages that have constraint rules automatically like:\n\n```Elixir\ndefmodule ProtoValidator.Gen.Examplepb.User do\n  @moduledoc false\n  use ProtoValidator, entity: Examplepb.User\n\n  validate(:id, required: true, uint64: [gt: 0, lt: 90])\n  validate(:email, required: true)\n  validate(:phones, repeated: [min_items: 1])\n\n  validate(:following_ids,\n    repeated: [items: [uint64: [gt: 0, lt: 90]], min_items: 0, unique: true]\n  )\nend\n\ndefmodule ProtoValidator.Gen.Examplepb.User.Phone do\n  @moduledoc false\n  use ProtoValidator, entity: Examplepb.User.Phone\n\n  validate(:phone_number, required: true, uint64: [gt: 1000, lt: 2000])\nend\n```\n\nThen both `\u0026ProtoValidator.validate/1` and `\u0026ProtoValidator.Gen.Examplepb.User/1` can be used to do the validation.\n\n```Elixir\nuser = Examplepb.User.new()\n{:error, _} = ProtoValidator.validate(user)\nusers = %{user | id: 1}\n{:error, _} = ProtoValidator.validate(user)\nusers = %{user | email: \"user@example.com\"}\n:ok = ProtoValidator.validate(user)\n:ok = ProtoValidator.Gen.Examplepb.User.validate(user)\n```\n\n## TODO\n\n- [ ] Numerics\n- [x] Bools\n- [x] Strings\n- [ ] Bytes\n- [ ] Enums\n- [ ] Messages\n- [ ] Repeated\n- [ ] Maps\n- [ ] Well-Known Types\n\n## How it works\n\nRefer: https://github.com/envoyproxy/protoc-gen-validate\n\n1. Google's Protobuf messages(like google.protobuf.MessageOptions) are extended with\n   validating rules(validate.proto)\n2. Your protobuf messages can use validate.proto to define validation options\n3. This plugin generate validating code when called by protoc. The code can be called\n   to validate messages\n4. Then you can validate your structs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabriziosestito%2Fprotoc-gen-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabriziosestito%2Fprotoc-gen-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabriziosestito%2Fprotoc-gen-validate/lists"}