0.0.5 • Published 6 years ago

cdi-joi-node v0.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

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

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago