-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MessageType.verify should accept all values that MessageType.toObject can produce #748
Comments
This is intended and that's why See: Valid Message Runtime message instances, as produced by Reasoning is that, if Btw., had to edit my answer multiple times to get this right. This stuff has clearly become too complex for a single README. I also start to worry that all those optimizations just make v6 too hard to use. Without it, it wouldn't be possible to encode half a million messages per second (referring to the benchmark, v5 was 10 times slower or something), though. |
I now also rephrased the Usage section in this regard. Hope this helps. |
OK, I think I understand now. |
We just encountered this discrepancy, in our situation we are transmitting json over the wire (from native GoLang/Java protobuf serializers ). We expected to call Specifically
gets serialized into
By both java and Golang reference implementations. But the
which is non standard? |
It's not non-standard, see: https://github.com/google/protobuf/blob/fd046f6263fb17383cafdbb25c361e3451c31105/src/google/protobuf/wrappers.proto#L99 There simply isn't a wrapper yet that deals with these types specifically, so the underlying .proto representation is used. |
From my understanding the
I guess the confusion is then, which method is meant to deserialize JSON , Thanks for helping clarify |
|
@dcodeIO I am using the version I would like to ensure the validation around missing required fields happens when using For a type described below
If given a plain Javascript object such as
But if I do decide to use Would there be a way whereby I could use |
This is an awesome library. It's such a joy to work dynamically with protobuf types like this. Which is why it's a bummer that I have the same issue as @dinesh-nadar. I want to be able to use the default JSON mapping of enums to protobuf which is strings (as documented here), and at the same time I still want to be able to verify the validity of the object I am working with. Right now I am using this code to pre-process the JSON objects calling |
protobuf.js version: 6.7.0
For some conversion options,
verify
appears to reject some values thattoObject
can produce. For example,longs: String
is a valid conversion option, but if a string is provided,verify
outputsuint_64: integer|Long expected
. Similarly,enums: String
is a valid conversion option, but if a string is provided,verify
outputsenum_value: enum value expected
.The text was updated successfully, but these errors were encountered: