protoc-gen-validate
protoc-gen-validate copied to clipboard
Support for well-known types like google.type.Decimal and google.type.Money
What's your stance on adding validation for well-known types? I'd like to add support for the following types:
- google.type.Money.
- google.protobuf.Timestamp
- google.type.PostalAddress
- google.type.Decimal
Alternately, is there a mechanism for adding validation on the fields of an external message?
Many of the WKTs are covered (including google.protobuf.Timestamp
), but I'm hesitant to suggest adding support for these other types as it's another dependency. The google.protobuf.*
WKTs are almost always bundled and special-cased by generator plugins and runtime libs, but the google.type.*
ones are not.
Alternately, is there a mechanism for adding validation on the fields of an external message?
Currently there is not, but it might be worth exploring side-loading validations for external types.
Ah, so WKT refers exclusively to google.protobuf.*
.
Feel free to close or repurpose for side-loading validations.
We're also interested in side-loading validations. We're currently using additional types not covered by this project like:
-
google.type.TimeOfDay
-
google.type.DayOfWeek
-
google.type.Date
We also wanted to side load validation as well. Currently we’re wrapping the Validate with another custom one.
do you have something in mind @rodaine? I was thinking on some kind of plugin system executed on build time.
I'm casually working on a simple plugin system, having some troubles with an existing issue in imports, but the general gist is there https://github.com/EmbedFi/protoc-gen-validate/pull/7
Does completed mean this is implemented or that it's out of scope?
+1
@daemonl i dont think i fully follow https://github.com/EmbedFi/protoc-gen-validate/pull/7, would you be able to share an example validating a well known type like a Date, Money, or just another complete pseudo example?
Thanks!
It's been a while, but we are using it in this project: https://github.com/EmbedFi/protoc-gen-validate-embedfi
It looks like this will be handled by V2, as described by the blog post: https://buf.build/blog/protoc-gen-validate-v1-and-v2/. I'll close this since v2 is probably the way forward.