cdi-joi-node

0.0.5 • Public • Published

cdi-joi-node

Build Status

Coverage Status

Library that assists in joi validator.

Installation

Requirements

  • NodeJS 8+

$ npm i cdi-joi-node

Usage

Simple

const CDI = require('cdi-node')
 
const plugin = require('cdi-joi-node')
 
const cdi = new CDI()
 
plugin(cdi)
 
const _module = cdi.configure({})
 
_module.schemaJoi = {
    fn: {
        a: Joi.string().required(),
        n: Joi.number().required(),
        h: Joi.number()
    }
}
 
_module.fn = ({ args }) => {
    return new Promise((resolve, reject) => {
        return resolve(args)
    })
}
 
try{
    await _module.fn({ args: { h : 'string'} })
} catch(err){
    // err: 'child "a" fails because ["a" is required]. child "n" fails because ["n" is required]. child "h" fails because ["h" must be a number]'
}
 

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i cdi-joi-node

Weekly Downloads

1

Version

0.0.5

License

ISC

Unpacked Size

6.93 kB

Total Files

8

Last publish

Collaborators

  • willguitaradmfar