0.0.1 • Published 7 years ago

@livelysoftware/kapow v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

kapow

Build Status Codacy Badge

Runtime function input validation using decorators and ow

Installation

npm install --save @livelysoftware/kapow

Example

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: string
    • Default: any
    • Validates provided input based on 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

7 years ago