# validate-json-schema-form

> Validate a form using JSON schema

Latest version **1.0.2** (published 2015-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install validate-json-schema-form
pnpm add validate-json-schema-form
yarn add validate-json-schema-form
bun add validate-json-schema-form
```

## 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 | 1.0.2 |
| Published | 2015-08-25 |
| First published | 2015-08-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Maintainers | yoshuawuyts |
| Keywords | json, schema, form, validate, html, json-schema |

## Links

- npm: https://www.npmjs.com/package/validate-json-schema-form
- Repository: https://github.com/yoshuawuyts/validate-json-schema-form
- Homepage: https://github.com/yoshuawuyts/validate-json-schema-form#readme
- Issues: https://github.com/yoshuawuyts/validate-json-schema-form/issues
- npm.io page: https://npm.io/package/validate-json-schema-form

## Dependencies (2)

- [get-form-data](https://npm.io/package/get-form-data.md) ^1.2.2
- [is-my-json-valid](https://npm.io/package/is-my-json-valid.md) ^2.12.1

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

- 1.0.2 (latest) — 2015-08-25
- 1.0.1 — 2015-08-25
- 1.0.0 — 2015-08-25

## README

# validate-json-schema-form
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![Downloads][downloads-image]][downloads-url]
[![js-standard-style][standard-image]][standard-url]

Validate a form using [JSON Schema][json-schema].

## Installation
```sh
$ npm install validate-json-schema-form
```

## Usage
```html
<form id="signup-form">
  <input name="username" type="text" placeholder="username"></input>
  <input name="password" type="password" placeholder="password"></input>
</form>
```

```js
const validator = require('validate-json-schema-form')

const validate = validator({
  required: [ 'username' ],
  type: 'object',
  properties: {
    username: { type: 'string' },
    password: { type: 'string' }
  }
})

const form = document.querySelector('#signup-form')
validate(form, (err, data) => {
  if (err) console.error(err)
  console.log(data)
})
```

## API
### validate = validator(schema)
Create a form validator out of a JSON Schema.

### validate(el, [opts], cb(err, data))
Validate a form element and call a callback with the results. Opts can contain
the following values:
- __[tbi]__ `partial=false` - set to `true` to only validate non-empty values.
- __[tbi]__ `formats` - define custom formats.
- __[tbi]__ `schemas` - reference external schemas.

## See Also
- [json-schema.org][json-schema]
- [is-my-json-valid](https://github.com/mafintosh/is-my-json-valid)

## License
[MIT](https://tldrlegal.com/license/mit-license)

[json-schema]: http://json-schema.org/

[npm-image]: https://img.shields.io/npm/v/validate-json-schema-form.svg?style=flat-square
[npm-url]: https://npmjs.org/package/validate-json-schema-form
[travis-image]: https://img.shields.io/travis/yoshuawuyts/validate-json-schema-form/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/yoshuawuyts/validate-json-schema-form
[codecov-image]: https://img.shields.io/codecov/c/github/yoshuawuyts/validate-json-schema-form/master.svg?style=flat-square
[codecov-url]: https://codecov.io/github/yoshuawuyts/validate-json-schema-form
[downloads-image]: http://img.shields.io/npm/dm/validate-json-schema-form.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/validate-json-schema-form
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: https://github.com/feross/standard

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