Joi extension for building airtight configurations
const Joi = require('joi')
.extend(require('joi-config'));
// Returns a validated configuration based on the contents of process.env
Joi.attempt(process.env, Joi.value({
server: {
host: 'localhost',
port: Joi.number().param('PORT').max(65535).default(3000),
},
register: {
plugins: [
{ plugin: '../lib' },
Joi.value({ plugin: 'hpal-debug' })
.whenParam('NODE_ENV', { is: 'production', then: Joi.strip() })
]
}
}));Hey!
You've probably noticed this documentation is filled with stubs and could use a lot of love. Rest assured, the library itself is in a complete state and is tested to 100% coverage. You can find lots of examples here in the readme as well as in the tests. The docs will be completed in the future, but please feel free to lend a hand by opening a PR to expand them.
Alias:
Joi.value(value, [options])
Alias:
Joi.param(param, [options])
Alias:
Joi.whenParam(param, options)
Alias:
Joi.p.x(template, [options])