0.0.1 • Published 8 years ago

tv4-mongodb v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

tv4-mongodb

About

Helper module for tv4 to validate against MongoDB ObjectId.

Install

$ npm install --save tv4 tv4-mongodb

Usage

const assert = require("assert");
const tv4 = require("tv4");

const validator = tv4.freshApi();
validator.addFormat(require("tv4-mongodb"));

const schema = { type: "string", format: "bson-objectid" };

assert(validator.validate("585d4f15d890997a4fb0d2e8", schema)); // Valid ObjectId
assert(!validator.validate("585d4f15d890997a4fb0d2z8", schema)); // Invalid ObjectId