# quick-jsonschema

> ## Overview This library builds on top of [jsonschema](https://github.com/tdegrunt/jsonschema) and make it less wordy. It simplifies 2 tings: * more concise validate function * many short-hand methods for building schema

Latest version **1.0.0** (published 2017-02-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install quick-jsonschema
pnpm add quick-jsonschema
yarn add quick-jsonschema
bun add quick-jsonschema
```

## 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.0 |
| Published | 2017-02-27 |
| First published | 2017-02-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=5.0.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | heartnetkung |

## Links

- npm: https://www.npmjs.com/package/quick-jsonschema
- Repository: https://github.com/heartnetkung/quick-jsonschema
- Homepage: https://github.com/heartnetkung/quick-jsonschema#readme
- Issues: https://github.com/heartnetkung/quick-jsonschema/issues
- npm.io page: https://npm.io/package/quick-jsonschema

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [jsonschema](https://npm.io/package/jsonschema.md) ^1.1.1

## Recent versions

- 1.0.0 (latest) — 2017-02-27

## README

# quick-jsonschema

## Overview
This library builds on top of [jsonschema](https://github.com/tdegrunt/jsonschema) and make it less wordy. It simplifies 2 tings:
* more concise validate function
* many short-hand methods for building schema

## Installation
```
npm install --save quick-jsonschema
```

## Validate API
```js
var q = require('quick-jsonschema');

// return false
q.validate({}, {type: 'object'});

// return { instance: ['does not meet minimum length of 1', 'does not match pattern "d+"'] }
q.validate('', { type: 'string', minLength: 1, pattern: '\d+' });

// return { 'instance[0]': ['is not of a type(s) string'], 'instance[1]': ['is not of a type(s) string'] }
q.validate([2, 3], { type: 'array', items: { type: 'string' } });

```

## Shorthand Methods API
* q.object(properties)
* q.array(items, minItems, maxItems)
* q.set(items, minItems, maxItems) //similar to array but all items are unique
* q.int(min, max)
* q.int.NATURAL
* q.int.POSITIVE
* q.number(minimum, maximum, exclusiveMinimum, exclusiveMaximum)
* q.string(pattern, minLength, maxLength)
* q.string.noHtml(minLength, maxLength)


Example

```js
var schema = q.object({ foo: q.int(42,45), bar: q.set(q.string(), 1) });
var data = { foo: 43, bar: ['a', 'b'] };
// return false
q.validate(data, schema);
```

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