Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAPIv2: consider Message.IsValidValue #958
Comments
|
Marking as Is this hypothetical, or did you have a real need for this? I've seen the use for a semi-related validation function. Something like |
|
I was updating a bit of code (previously Go reflection, now protoreflect) that copies a list of named fields from one message to another message of a different type. There's no simple way to catch a field type mismatch; you can compare the descriptors, but that won't catch the (admittedly unusual) case where the descriptors are the same but the Go types aren't. It's nothing you can't work around, but got me wondering whether there should be an easy way to do this for non-extension fields. |
|
Nice to have, but we both agreed that the use cases didn't seem all that compelling. |
Should we have a way to test a Value for compatibility with a message field, along the lines of ExtensionType.IsValidValue?
This could either be a method on MessageType or Message.