-
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
Checking if a field with a default value has been set #200
Comments
Currently there is no way to determine if the values have been explicitly set with the default value. There is, however, the possibility to check if the value equals the default value: var myMessage = MyMessage.decode(...);
if (myMessage.someField === myMessage.$type.getChild("someField").defaultValue) {
...
} |
The official C++ and Java implementations provide Consider a Message object
This API could be implemented by using inheritance. I can produce a proof-of-concept if anyone is interested. |
Closing this for now. Feel free to send a pull request if this is still a requirement. |
I'm trying to figure out if an optional field has been set in a proto. Can you please explain how to check if a field has been set. Currently, I'm observing that if a field has a default value and is not set, then on decoding, the object contains the default value. How can we distinguish this from the case where the field was indeed set with the same value as the default?
Thanks!
The text was updated successfully, but these errors were encountered: