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

Dependents (0)

Package Sidebar

Install

npm i ensure-params

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

15.2 kB

Total Files

11

Last publish

Collaborators

  • superfaz