# @vasuvanka/json-validator

> general purpose json schema validator

Latest version **0.0.7** (published 2020-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vasuvanka/json-validator
pnpm add @vasuvanka/json-validator
yarn add @vasuvanka/json-validator
bun add @vasuvanka/json-validator
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2020-11-15 |
| First published | 2020-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | vasuvanka |
| Keywords | type validator, object validator, json validator, json schema validator, type checker |

## Links

- npm: https://www.npmjs.com/package/@vasuvanka/json-validator
- Repository: https://github.com/vasuvanka/json-validator
- Homepage: https://github.com/vasuvanka/json-validator#readme
- Issues: https://github.com/vasuvanka/json-validator/issues
- npm.io page: https://npm.io/package/@vasuvanka/json-validator

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 0.0.7 (latest) — 2020-11-15
- 0.0.6 — 2020-11-15
- 0.0.5 — 2020-05-14
- 0.0.4 — 2020-04-18
- 0.0.3 — 2020-04-18
- 0.0.2 — 2020-04-18
- 0.0.1 — 2020-04-13

## README

# json-validator for Node.js / deno

Json Validator - validates a json object against defined schema.

## Install

```
npm install @vasuvanka/json-validator
```

## Docs

- API Documentation: https://vasuvanka.github.io/json-validator

## Deno Example

```ts
import { validate } from "https://deno.land/x/jsonvalidator/index.ts";
const bodySchema = {
  name: {
    type: String,
  },
  phone: { type: Number },
  isLoggedIn: { type: Boolean },
  address: {
    line: {
      add: [{ type: Number }],
    },
    street: { type: String },
    city: { type: String },
    pincode: { type: Number },
  },
  list: [{ type: String }],
};

const body = {
  name: "Hello",
  phone: 88010000000,
  address: {
    line: {
      add: [1],
    },
    street: "streetlk111",
    city: "some city",
    pincode: 453672,
  },
  isLoggedIn: false,
  list: ["hello", "world"],
};
const error = validate(body, bodySchema, { allowUnknown: true });
console.log(error);

const err = validate(body, bodySchema, { allowUnknown: false });
console.log(err);
```

## Node.js Example

```js
const { validate } = require("@vasuvanka/json-validator");

const bodySchema = {
  name: {
    type: String,
  },
  phone: { type: Number },
  isLoggedIn: { type: Boolean },
  address: {
    line: {
      add: [{ type: Number }],
    },
    street: { type: String },
    city: { type: String },
    pincode: { type: Number },
  },
  list: [{ type: String }],
};

const body = {
  name: "Hello",
  phone: 88010000000,
  address: {
    line: {
      add: [1],
    },
    street: "streetlk111",
    city: "some city",
    pincode: 453672,
  },
  isLoggedIn: false,
  list: ["hello", "world"],
};
const error = validate(body, bodySchema);
console.log(error);

const err = validate(body, bodySchema, { allowUnknown: false });
console.log(err);
```

## LICENCE

MIT

## Free software,hell ya.

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