validity-string-represents-mongodb-objectid

0.1.3 • Public • Published

validity-string-represents-mongodb-objectid

Validity style validator to ensure a property is an Object ID.

Installation

  npm install validity-string-represents-mongodb-objectid

Usage

Below is a simple example for usage with schemata:

 
var validity = require('validity')
  , schemata = require('schemata')
  , stringRepresentsObjectId = require('validity-string-represents-mongodb-objectid')
 
var schema = schemata(
    { linkedObjectId:
      { type: String
      , validators:
        { all: [stringRepresentsObjectId()]
        }
      }
      , otherObjectId:
      { type: String
      }
    })
 
schema.validate({ linkedObjectId: 'noidhere', linkedObjectId: 'notanid' }, function (error, valid) {
  // Show the error
  console.log(valid)
})
 

Credits

Tom Gallacher follow me on twitter @tomgco

Licence

Licensed under the MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i validity-string-represents-mongodb-objectid

Weekly Downloads

0

Version

0.1.3

License

MIT

Last publish

Collaborators

  • tomgco