validate-objectid Usage var objectid = require('validate-objectid'); assert(! objectid('test')); assert(objectid('542f9cabed89afee4aaf2e61'));