0.0.5 • Published 7 years ago

overhaul v0.0.5

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

Overhaul

Type Checking, Formatting, Annotations, & more

npm version

Table of Contents

Quick Start

const oh = require("overhaul");

let format = oh.object({
  id: oh.required.toString.description("User Id"),
  state: oh.default("WA").values(["CA", "OR", "WA"]),
  age: oh.integer.within(10, 20).deprecated,
  filter: oh.object({
    start: oh.default(0).toNumber,
    end: oh.default(() => 5000).number
  })
});

let req = format.value({
  id: 123,
  age: 15,
  filter: {start: "100"}
});

// req === { id: '123', age: 15, state: 'WA', filter: { start: 100, end: 5000 } }

Usage

Constructor

Value

Register

Definition

Serialize

↑ Back to top

Definitions

Types

Arguments

Array

Boolean

Date

Element

Empty

Error

Finite

Instance

NaN

Null

Number

Object (Plain Object)

//Shortcut
oh.object({
  id: oh.string,
  filter: oh.object({
    start: oh.number,
    end: oh.number
  })
})

// Is equivalent to:
oh.object({
  id: oh.string,
  filter: {
    start: oh.number,
    end: oh.number
  }
})

// oh.object is implied if inner key value is a plain object

RegExp

String

Undefined

Traversals

Copy

Delete

Index

Key

Move

Parent

Sibling

Modifiers

Default

Freeze

Noop

Parse

Required

Stringify

Annotations

Example

Description

Deprecated

Lodash

https://lodash.com/docs

↑ Back to top

Installation

npm install --save overhaul

↑ Back to top

License

overhaul is licensed under the MIT license.

↑ Back to top