# validate2

> 简单的表单验证

Latest version **0.0.3** (published 2014-04-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install validate2
pnpm add validate2
yarn add validate2
bun add validate2
```

## 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.3 |
| Published | 2014-04-08 |
| First published | 2014-04-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | cloudcome |
| Maintainers | cloudcome |
| Keywords | validate, form |

## Links

- npm: https://www.npmjs.com/package/validate2
- npm.io page: https://npm.io/package/validate2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2014-04-08
- 0.0.2 — 2014-04-07
- 0.0.1 — 2014-04-07
- 0.0.0 — 2014-04-07

## README

# 简单的表单验证

因validate已被占用，故加了个2后缀

![validate2](https://nodei.co/npm/validate2.png?downloads=true&amp;stars=true)

# 安装
```{bash}
npm install validate2
```

#使用
```{javascript}
var validate2 = new Validate2();

var body = {
	username: 'cloudcome',
	password: '123123',
	password2: '12312ddd3',
	email: 'cloudcome@163.co--m',
};


// setting
validate2.set({
	isSkipInvalid: true,
	body: body,
})
// username
.item('username', [{
	type: 'username',
	settings: {
		minLength: 2,
		maxLength: 3,
	},
	msg: '用户名不合法！',
}])
// password
.item('password', [{
	type: 'password',
	settings: {
		minLength: 2,
		maxLength: 3,
	},
	msg: '密码不合法！',
}])
// password2
.item('password2', [{
	type: 'password',
	msg: '确认密码不合法！',
}, {
	type: 'equal',
	name: 'password',
	msg: '确认密码不一致！',
}])
// email
.item('email', [{
	type: 'email',
	msg: '邮箱不合法！',
}])
// listen
.on('end', function (msg) {
	console.log(msg);
})
// run validate
.validate();
```

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