# daccord-validation

> Validation library.

Latest version **2.1.0** (published 2016-04-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install daccord-validation
pnpm add daccord-validation
yarn add daccord-validation
bun add daccord-validation
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2016-04-20 |
| First published | 2015-09-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Nic Bell |
| Maintainers | nicbell |
| Keywords | validation, kickoff |

## Links

- npm: https://www.npmjs.com/package/daccord-validation
- Repository: https://nicbell@github.com/nicbell/daccord
- Homepage: https://github.com/nicbell/daccord#readme
- Issues: https://github.com/nicbell/daccord/issues
- npm.io page: https://npm.io/package/daccord-validation

## Dependencies (1)

- [object-assign](https://npm.io/package/object-assign.md) ^4.0.1

## 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

- 2.1.0 (latest) — 2016-04-20
- 2.0.1 — 2015-11-03
- 2.0.0 — 2015-11-03
- 1.0.0 — 2015-09-17

## README

D’accord
======
Kickoff validation plugin for forms. Uses HTML 5 form attributes to trigger validation tests.

Usage
---
```js
var Daccord = require('daccord-validation');
new Daccord(document.querySelector('form'));
//or
new Daccord(document.querySelector('form'), options);
```
```html
<form class="l-container" action="/somewhere">
	<div class="form-controlGroup">
		<label class="form-label" for="field1">Text, required, maxlength 10</label>
		<input class="form-input" id="field1" name="field1" type="text" required maxlength="10">
	</div>
	<div class="form-controlGroup">
		<label class="form-label" for="field2">Email, required</label>
		<input class="form-input" id="field2" name="field2" type="email" required>
	</div>
	<div class="form-controlGroup">
		<label class="form-label" for="field3">Text, required with message</label>
		<input class="form-input" id="field3" name="field3" type="text" data-val-required="This field is required" required>
		<div class="form-message"></div>
	</div>
	<button class="btn btn--primary" type="submit">Submit</button>
</form>
```
Error messages are shown if there is an element with the class of ```form-message``` in the same ```form-controlGroup``` as the input field.

```has-error``` and ```has-success``` are added to the ```form-controlGroup``` to indicate success or failure.

Options
---
#### fields
Type: `String`  
Default: `input, select, textarea`

Fields to validate.

#### inlineErrors
Type: `Boolean`  
Default: `false`

#### errorClass
Type: `String`  
Default: `has-error`

#### successClass
Type: `String`  
Default: `has-success`

#### focus
Type: `Boolean`  
Default: `false`

#### liveValidation
Type: `Boolean`  
Default: `false`

API
---

| Rule | Triggered by | Error message  |
--- | --- | ---
| Required field | ```required``` or ```data-val-required``` attribute | ```data-val-required="Message"``` |
| Max length | ```maxlength="num"``` or ```data-val-length-max="num"``` | ```data-val-length="Message"``` |
| Min length | ```minlength="num"``` or ```data-val-length-min="num"``` | ```data-val-length="Message"``` |
| Pattern | ```pattern="regex"``` or ```data-val-regex-pattern="regex"``` | ```data-val-regex="Message"``` |
| Email | ```type="email"``` | ```data-val-email="Message"``` |
| Matches | ```data-val-equalto-other="name of other"``` | ```data-val-equalto="Message"``` |

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