Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

liqd-options

radixxko3MIT1.0.8

Options validation library

options, validation, liqd

readme

Options validation library

NPM version Build Status Coverage Status NPM downloads Known Vulnerabilities MIT License

Validate options like a PRO!

const options =
{
    port: 80,
    frame:
    {
        compression:
        {
            treshold: 2048  
        }
    },
    client:
    {
        accept : () => true
    }
};

this._options = Options( options,
{
    server    : { _required: false, _passes: $ => $ instanceof Server },
    tls        : { _required: false, _type: 'object' },
    port    : { _required: true, _convert: parseInt },
    version : { _any: [ 8, 13 ] }
    frame    :
    {
        _expand    : true,

        mask    : { _type: 'boolean', _default: false },
        limit    : { _type: 'number', _default: 100 * 1024 * 1024, _convert: $ => Math.min( $, 100 * 1024 * 1024 )},
        compression    :
        {
            _default: false, _expand: true,

            treshold: { _type: 'number', _default: 1024 }
        }
    },
    client    :
    {
        _expand    : true,

        accept    : { _type: 'function' }
    }
});