objectid-validator
FindById method in mongoose will give errors if object id is not in correct format. This module help to validate object id to avoid errors. It works as a middleware like bodymen.
Installation
npm install objectid-validator
Usage
; router;// This will return Network status code 400 with error messages if "id" in "req.body" is not valid router;// This will return Network status code 400 with error messages if "id" in "req.params" is not valid router;// This will return Network status code 400 with error messages if "id" in "req.params" is not valid// And it will not validate "id" if we passed string "me" instead of an ObjectId