# hui-validator

> a simple javascript validate function

Latest version **0.0.5** (published 2019-01-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install hui-validator
pnpm add hui-validator
yarn add hui-validator
bun add hui-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.0.5 |
| Published | 2019-01-14 |
| First published | 2019-01-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | alucardlockon |
| Maintainers | alucardlockon |
| Keywords | validator, hui |

## Links

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

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2019-01-14
- 0.0.4 — 2019-01-14
- 0.0.3 — 2019-01-14
- 0.0.2 — 2019-01-14
- 0.0.1 — 2019-01-14

## README

# hui-validator
简单的js验证组件

```
npm i hui-validator
```

规则示例
```javascript
import huiValidator from 'hui-validator'

const rules = [
 {prop:'usernmae',name:'用户名', type:'notnull', max: 10, min: 3, message:'用户名不能为空'},
 {prop:'age',name:'number', type:'regexp', regexp: /\d+/, nullable: true }
]

// 参数分别为验证对象,验证规则，失败回调(用来显示消息)
huiValidator(valueObj,rules,console.log)

```

## 非空
`nullable`表示这个属性不能为null

## 内置规则(type)

```
    非空 notnull
    整形数字 number
    小数 float
    数字或小数 nmmberOrFloat
    身份证 idCard
    手机号 phone
    日期 yyyy-MM-dd date
    日期时间 yyyy-MM-dd hh:mm:ss
    扩展: 正则 regexp,需要参数regexp
```


## onValidateFail回调
```
三个参数分别为默认消息，验证规则和验证值
```

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