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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    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