ensure-params

    0.0.1 • Public • Published

    ensure-params

    Provide simple checks for method / function parameters.

    installation

    npm install --save ensure-params

    usage

    const ensure = require('ensure-params')
    
    class HelloSomeone {
      static print (name) {
        ensure.param('name', name)
          .isRequired()
          .isString()
        console.log('Hello ' + name)
      }
    }
    
    HelloSomeone.print('test') // will succeed
    HelloSomeone.print() // will fail and throws an error
    HelloSomeone.print(null) // will fail and throws an error
    HelloSomeone.print(1) // will fail and throws an error
    

    Keywords

    Install

    npm i ensure-params

    DownloadsWeekly Downloads

    1

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    15.2 kB

    Total Files

    11

    Last publish

    Collaborators

    • superfaz