liqd-options

1.0.8 • Public • Published

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' }
    }
});

Readme

Keywords

Package Sidebar

Install

npm i liqd-options

Weekly Downloads

6

Version

1.0.8

License

MIT

Unpacked Size

6.71 kB

Total Files

4

Last publish

Collaborators

  • radixxko