0.0.1 • Published 8 years ago
@livelysoftware/kapow v0.0.1
kapow
Runtime function input validation using decorators and ow
Installation
npm install --save @livelysoftware/kapowExample
import { kapow, validate } from "@livelysoftware/kapow";
class MyClass {
constructor() {}
@validate
add(
@kapow({
required: true,
type: "number"
}) a,
@kapow({
required: true,
type: "number"
}) b
) {
/*
If a and/or b are not provided and/or
not of type "number" then an error will be thrown
*/
return a + b;
}
}Supported Options
required- Type:
boolean - Default:
false - When set to true, throws an error if the parameter does not exist
- Type:
type- Type:
string - Default:
any - Validates provided input based on type
- Type:
TODO
- Full (or as much as possible) API support for ow
- Tests for all available options
- Reduce required syntax if possible (looking at you,
@validate)
0.0.1
8 years ago