joi-mongoose-objectid
Joi extension to validate MongoDB objectId with mongoose
use
joi-mongoose-objectid
give you the Joi.objectId()
function that validate the input with mongoose.Types.ObjectId.isValid(value)
.
It is a Joi extension so you should extends Joi with it. Then you can extend Joi with other extensions.
let Joi = ;const joiObjectIdExtension = ; Joi = Joi; const schema = Joiobject id: Joi name: Joi date: Joi; schema;
Installation
npm install joi-mongoose-objectid
OR
yarn add joi-mongoose-objectid
Tests
There is two simple tests on the test.js file. One for success and one for failure. To run tests :
npm run test
OR
yarn test