-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Unknown
-
None
-
Affects Version/s: 4.13.0
-
Component/s: BSON
-
None
What problem are you facing?
ObjectId constructor accepts invalid Strings as long as they have 12 bytes length.
What driver and relevant dependency versions are you using?
Node 16, Mongo driver v4.13.0, BSON 4.7.0
Steps to reproduce?
// the constructor will not throw an error and // it will create an invalid ObjectID const id = new ObjectId(`I'm 12 bytes`) console.log(id) const valid = ObjectId.isValid(`I'm 12 bytes`) console.log(id) // prints true