Joi extension to validate MongoDB ObjectId. Version 0.1.0 is stable, released in 2018, with no further updates. Provides a single `.objectId()` Joi type that validates BSON ObjectId instances. Depends on `joi >= 13` and `bson`. Minimal alternative to custom validators in Joi schemas for MongoDB applications.
npm install joi-mongodb-objectidNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to extend Joi with the ObjectId type and validate a valid and invalid ObjectId.
Use an updated fork or implement custom validation.
Use 'joi@16' or adopt Joi v17 with new extension format.
Convert hex strings to ObjectId before validation or use a different validator.
const Joi = require('joi').extend(require('joi-mongodb-objectid'));const objectId = new (require('bson').ObjectId)(hexString); then validate.npm install bson