# n-validator

> js type validate

Latest version **0.2.1** (published 2017-12-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install n-validator
pnpm add n-validator
yarn add n-validator
bun add n-validator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2017-12-14 |
| First published | 2017-12-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ReAlign |
| Maintainers | realign |
| Keywords | js, validate |

## Links

- npm: https://www.npmjs.com/package/n-validator
- Repository: https://github.com/ReAlign/n-validator
- Homepage: https://github.com/ReAlign/n-validator#readme
- Issues: https://github.com/ReAlign/n-validator/issues
- npm.io page: https://npm.io/package/n-validator

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.2.1 (latest) — 2017-12-14
- 0.2.0 — 2017-12-13
- 0.1.8 — 2017-12-13
- 0.1.7 — 2017-12-13
- 0.1.6 — 2017-12-13
- 0.1.4 — 2017-12-11
- 0.1.3 — 2017-12-10
- 0.1.2 — 2017-12-09
- 0.1.1 — 2017-12-09
- 0.1.0 — 2017-12-09
- 0.0.1 — 2017-12-04

## README

# n-validator
[![codecov][codecov-image]][codecov-url]

[codecov-url]: https://codecov.io/gh/ReAlign/n-validator
[codecov-image]: https://codecov.io/gh/ReAlign/n-validator/branch/master/graph/badge.svg

#### 前提：目前前端 `mock`， 只做了 `url` & `method` 校验。

这种情况下，前端几乎不太会去关心接口 `具体参数` 的格式，所以，前端的自测，一般在 `mock` 环境下通过，就算是通过了。但是跟后端联调各种格式问题。

所以，想在前端 `mock` 环境下，搞一套类似 `静态类型检查` 的东西，初始生成 `mock` 数据的时候，就定好 `参数格式规则` ，省去前后端联调时再去 `订正` 数据格式的时间，提高效率。


## Validator

| Method | Description |
| --- | --- |
| isInt(str, [, options]) | check if the variable is an integer. |
| isFloat(str, [, options]) | check if the variable is a float. |
| isDate(str, [, options]) | check if the string is a date string. |
| isDateTime(str, [, options]) | check if the string is a date-time string. |
| isBoolean(val, [, options]) | check if the variable is a boolean. |
| isLength(str, [, options]) | check if the string's length falls in a range. ( [min, max] ) |
| isRequired(str) | check if the variable required. |

## todo

* [ ] isFloat, decimal digits(0.10: 2?1)
* [ ] number strictMode
* [ ] date stamp

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