1.0.2 • Published 1 year ago

ts-joi-objectid v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

joi-objectid

A MongoDB ObjectId validator for Joi with types! Package based on joi-objectid

use

joi-objectid validates that the value is an alphanumeric string of 24 characters in length.

It's used just like you'd use any other Joi type.

import { joiObjectId } from 'ts-joi-objectid';
const joi_oid = joiObjectId(Joi);

let schema: Joi.ObjectSchema = Joi.object({
  id: joi_oid().required(),
  name: Joi.string().max(100),
  date: Joi.date()
})

Installation

npm install joi-objectid --save

Development

npm run dev

License

MIT