options-resolver
v1.0.1
Published
Port of Symfony component OptionsResolver. This library processes and validates option object
Downloads
81
Maintainers
Readme
OptionsResolver
This is a port of awesome Symfony component OptionsResolver. This library processes and validates option object.
Installation
npm install options-resolver --save
Usage
import createResolver from 'options-resolver';
const resolver = createResolver();
resolver
.setDefaults({
'foo': 'bar',
'baz': 'bam'
})
.setRequired('foo')
.setAllowedTypes('foo', 'string')
.setAllowedValues('foo', ['bar', 'one'])
;
resolver.resolve({
'foo': 'one'
}).then((options) => {
// options is equal to :
// {
// 'foo': 'one',
// 'baz': 'bam'
// }
});
Run tests
npm run test
TODO
- Improve documentation
- Add Express middleware
Release History
- 1.0.0 First release