Skip to content

Extending Joi to validate and convert mongo/mongoose ObjectId

License

Notifications You must be signed in to change notification settings

EkoCommunications/EkoJoiObjectId

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status npm version Code Climate Dependencies

EkoJoiObjectId

Extending Joi to validate and convert mongo/mongoose ObjectId

Installation

$ npm install eko-joi-objectid --save

Usage Example

var Joi = require('joi');
var ObjectId = require('mongoose').Types.ObjectId;
Joi.objectId = require('eko-joi-objectid')(Joi, ObjectId);

var someObjectId = (new ObjectId()).toString();
var result = Joi.attempt(someObjectId, Joi.ObjectId());

result instanceof ObjectId; // => true

Tests

npm test

About

Extending Joi to validate and convert mongo/mongoose ObjectId

Resources

License

Stars

Watchers

Forks

Packages

No packages published