This is in reference to the comment here.
The struct decoder should have the ability to report non-existent field. Go's json decoder has support for this documented here. I've played around this a bit, and the quickest way to implement this would be potentially exposing a similar function in the RegistryBuilder`. All decoders have a reference to the registry through DocodeContext.
Definition of done
- Add a configuration that causes decoding to return an error if there are fields in the decoded BSON document that don't match fields in the decode destination struct. Note that this only makes sense when the destination is a struct.
- Add the ability to configure that unmarshal behavior on a MongoDB Client using BSONOptions.
Pitfalls
- Adds additional configuration to the bson.Decoder type, which already has a lot of configurable behaviors.
- is duplicated by
-
GODRIVER-3044 Error when unmarshaling a BSON document if the document has unknown fields
- Closed