-
Type: New Feature
-
Resolution: Duplicate
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: BSON
-
None
Context
Some users want the ability to configure a BSON decoder to return an error if the BSON document has fields that don't match fields in the decode destination struct. The Go "encoding/json" library supports a similar configuration called Decoder.DisallowUnknownFields . We should support something similar for the BSON decoder.
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.
- duplicates
-
GODRIVER-1121 Error when unmarshaling a BSON document if the document has unknown fields
- Backlog