# another-form-validator

> A framework agnostic, customizable form validator

Latest version **0.1.5** (published 2019-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install another-form-validator
pnpm add another-form-validator
yarn add another-form-validator
bun add another-form-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.1.5 |
| Published | 2019-04-03 |
| First published | 2019-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 204.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alexander Whitaker |
| Maintainers | adwhitaker |

## Links

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

## Recent versions

- 0.1.5 (latest) — 2019-04-03

## README

# Another Form Validator

> A framework agnostic, customizable form validator

[![NPM Version][npm-image]][npm-url]

## Install
```bash
npm install another-form-validator
```

## Usage
```js
import FormValidator from 'another-form-validator'

let model = {
    pineapple: 1
}

const formValidator = new FormValidator()

formValidator.registerField({
    name: 'pineapple',
    model: () => model.pineapple,
    validators: [{
        getError: () => 'multiple pineapples are required',
        validate: (value) => value > 1
    }],
    onChange: [
        (field) => {
            // called on field events (touch, dirty, validate)
            if (field.errors.length) {
                const errorToDisplay = field.errors[0]
            }
        }
    ]
})

model.pineapple = 2

formValidator.touch('pineapple')
formValidator.dirty('pineapple')

const formIsValid = formValidator.validate()
console.log(formIsValid) // true
```

## License

[MIT](http://vjpr.mit-license.org)

[npm-image]: https://img.shields.io/npm/v/another-form-validator.svg
[npm-url]: https://npmjs.org/package/another-form-validator

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