provejs-params

1.0.1 • Public • Published

provejs-params

Prove function parameters using a simple schema.

Install

npm install provejs-params --save

Usage

var Prove = require('provejs-params');
 
function myFunction(myArray, myNumber) {
    Prove('AN', arguments);
}
 
myFunction([], []); // bug here

will result in

{ Error: Argument #2: Expected `number` but got `array` 
    at myFunction (/Users/dan/repos/.../test.js:122:2)
    at Object.<anonymous> (/Users/dan/repos/.../test.js:125:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3 code: 'EINVALIDTYPE' }

Supported Types

Letter Data Types Required
* matches any type true
A Array or Arguments true
S String true
N Number true
M Finite Number true
F Function true
O Object true
B Boolean true
G Arguments true
E Error true
a Array or Arguments false
s String false
n Number false
m Finite Number false
f Function false
o Object false
b Boolean false
g Arguments false
e Error false

This work was inspired by: https://github.com/iarna/aproba

Package Sidebar

Install

npm i provejs-params

Weekly Downloads

96

Version

1.0.1

License

MIT

Last publish

Collaborators

  • dhollenbeck