# param-check

> A js library for runtime parameter checking.

Latest version **2.1.3** (published 2018-11-27) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install param-check
pnpm add param-check
yarn add param-check
bun add param-check
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.3 |
| Published | 2018-11-27 |
| First published | 2016-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Y3G |
| Maintainers | y3g, yusangeng |

## Links

- npm: https://www.npmjs.com/package/param-check
- Repository: https://github.com/yusangeng/param-check
- Homepage: https://github.com/yusangeng/param-check#readme
- Issues: https://github.com/yusangeng/param-check/issues
- npm.io page: https://npm.io/package/param-check

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## Recent versions

- 2.1.3 (latest) — 2018-11-27
- 2.1.2 — 2018-08-07
- 2.1.1 — 2018-05-24
- 2.1.0 — 2018-05-18
- 2.0.0 — 2018-04-17
- 1.1.9 — 2018-01-20
- 1.1.8 — 2017-08-05
- 1.1.7 — 2017-08-05
- 1.1.5 — 2017-07-13
- 1.1.4 — 2017-07-13
- 1.1.3 — 2017-07-13
- 1.1.2 — 2017-04-24
- 1.1.1 — 2017-04-23
- 1.1.0 — 2017-03-29
- 0.2.6 — 2016-09-13
- … 6 more at https://npm.io/package/param-check/versions

## README

# param-check

[![Build Status](https://travis-ci.org/yusangeng/param-check.svg?branch=master)](https://travis-ci.org/yusangeng/param-check) [![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

[![Npm Info](https://nodei.co/npm/param-check.png?compact=true)](https://www.npmjs.com/package/param-check)

运行时数据校验工具 | a javascript run-time data verification tool.

## Install

```
npm install param-check --save
```

## Usage

### Basic usage

``` js
import check from 'param-check'

function fn (arg1, arg2) {
	check(arg1).isString()
	check(arg2, 'arg2').greaterThan(1).lessThan(2)
}
```

### Import of specific check

``` js
import check from 'param-check/naked'
import isStringCheck from 'param-check/lib/checks/isString'

check.registerCheck(isStringCheck)

function fn (arg) {
	check(arg, 'arg').isString()
}
```

### Custom check

``` js
import check from 'param-check'
import isNumber from 'lodash/isNumber'

function isEven (target, name) {
  return isNumber(target) && !(target % 2)
}

check.registerCheck('isEven', isEven)

function fn (arg) {
	check(arg, 'arg').isEven()
}
```

### Custom linkable check

``` js
import check from 'param-check'
import isNumber from 'lodash/isNumber'

function isEven (target, name) {
  return isNumber(target) && !(target % 2)
}

function isEventNext (target) {
  return return target + 1
}

check.registerCheck('isEven', isEven, isEventNext)

function fn (arg) {
	check(arg, 'arg').isEven().isEven() // error occurred
}
```

---
_Source: https://npm.io/package/param-check · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
