JSPM

options-resolver

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 23
  • Score
    100M100P100Q51503F
  • License MIT

Port of Symfony component OptionsResolver. This library processes and validates option object

Package Exports

  • options-resolver

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (options-resolver) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OptionsResolver

This is a port of awesome Symfony component OptionsResolver. This library processes and validates option object.

Build Status

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