How can I check whether an ObjectID is valid using Node\'s driver
I tried :
var BSON = mongo.BSONPure; console.log(\"Validity: \" + BSON.ObjectID.is
Follow this regular expression :
in js
new RegExp("^[0-9a-fA-F]{23}$").test("5e79d319ab5bfb2a9ea4239")
in java
Pattern.compile("^[0-9a-fA-F]{23}$").matcher(sanitizeText(value)).matches()