bufbuild / protovalidate-go

Protocol Buffer Validation for Go
https://pkg.go.dev/github.com/bufbuild/protovalidate-go
Apache License 2.0
294 stars 19 forks source link

Add support for protobuf editions #146

Closed maxprofit closed 2 months ago

maxprofit commented 2 months ago

Feature description: Protobuf editions should be supported

Problem it solves or use case: As it seems to be the next move for the protobuf syntax, this library should move to support the new syntax and changes. My current error is as follows.

Failure: plugin "buf.build/bufbuild/validate-go" does not support feature "supports editions" which is required by "my.proto"

Proposed implementation or solution: Implement the changes as specified by the edition 2023 to start.

Contribution: I might be able to take this on when I get some time, but I can definitely help others if they're willing to take it on in any way I can.

Examples or references: N/A

Additional context: Should be pretty self-explanatory, feel free to ping me if any questions

jhump commented 2 months ago

@MaxProfit, this repo does not have any proto plugins. The plugin you referenced is actually for this repo: https://github.com/bufbuild/protoc-gen-validate

Note that repo is deprecated. This repo is its replacement. This repo relies on runtime reflection, not code generation. And it does support Editions. We highly recommend upgrading.

When you upgrade, you can even leave the existing annotations in your protos and just include legacy support when you create a validator. Note however that the legacy support is purely transitional -- you should also update all of your proto sources to use the new custom options, but you can do that over time instead of having to do everything at once (or worse, have both annotations on everything for some period). We plan to eventually drop the legacy support, in a final v1.0 of this repo, so you'll need to migrate your options over (which should be mechanical and fairly painless) before you could upgrade to a future v1.0.

rodaine commented 2 months ago

Adding onto @jhump's response about legacy support, protovalidate also has a migration utility that will perform the updates from PGV to protovalidate for you.

maxprofit commented 2 months ago

@jhump Ah that makes sense! Thank you! I'm even using protovalidate in my buf.gen.yaml so I must've just included this incorrectly!