Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.
/ joi-mongodb Public archive

A simple Joi validator for MongoDB ObjectId.

License

Notifications You must be signed in to change notification settings

paulsmithkc/joi-mongodb

Repository files navigation

joi-mongodb

Joi custom validator for MongoDB ObjectId.

Install

npm install joi-mongodb

Usage

In your application entry point (index.js/server.js/app.js):

const Joi = require('joi');
require('joi-mongodb')(Joi);

Then it can be used just like any other Joi type:

const schema = Joi.object({
  _id: Joi.objectId(),
  name: Joi.string(),
  date: Joi.date(),
});

Similar Packages