Extensions for Joi validator.
Installation
npm install @joi-extensions/joi-extensions
Usage
Usage is a two steps process. First, a schema is constructed using the provided types and constraints:
const BaseJoi = require('joi')
const {AnyExtensions} = require('@joi-extensions/joi-extensions')
const Joi = BaseJoi.extend(AnyExtensions)
const schema = Joi.any().sizeof(20)
const BaseJoi = require('joi')
const {StringExtensions} = require('@joi-extensions/joi-extensions')
const Joi = BaseJoi.extend(StringExtensions)
const schema = Joi.string().objectId()
const BaseJoi = require('joi')
const {ArrayExtensions} = require('@joi-extensions/joi-extensions')
const Joi = BaseJoi.extend(ArrayExtensions)
const schema = Joi.array().even()
API
See the detailed API Reference.