# ajv-bsontype

> adds mongodb's bsonType validators

Latest version **1.0.7** (published 2019-05-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install ajv-bsontype
pnpm add ajv-bsontype
yarn add ajv-bsontype
bun add ajv-bsontype
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2019-05-28 |
| First published | 2018-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/ajv-bsontype) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | BoLaMN |
| Maintainers | bolamn |

## Links

- npm: https://www.npmjs.com/package/ajv-bsontype
- Repository: https://github.com/BoLaMN/ajv-bsontype
- Homepage: https://github.com/BoLaMN/ajv-bsontype#readme
- Issues: https://github.com/BoLaMN/ajv-bsontype/issues
- npm.io page: https://npm.io/package/ajv-bsontype

## Recent versions

- 1.0.7 (latest) — 2019-05-28
- 1.0.6 — 2018-09-29
- 1.0.5 — 2018-09-21
- 1.0.4 — 2018-08-17
- 1.0.3 — 2018-08-17
- 1.0.2 — 2018-08-10
- 1.0.1 — 2018-08-10
- 1.0.0 — 2018-08-10

## README

# ajv-bsontype

adds mongodb's bsonType validators

* npm install ajv-bsontype --save

## Setup

```
var Ajv = require('ajv');
var ajv = new Ajv;
require('ajv-bsontype')(ajv);
```

### Usage

```
const schema = {
   required: [ "name", "year", "major", "gpa" ],
   properties: {
      name: {
         bsonType: "string",
         description: "must be a string and is required"
      },
      gender: {
         bsonType: "string",
         description: "must be a string and is not required"
      },
      year: {
         bsonType: "int",
         description: "must be an integer in [ 2017, 3017 ] and is required"
      },
      major: {
         enum: [ "Math", "English", "Computer Science", "History", null ],
         description: "can only be one of the enum values and is required"
      },
      gpa: {
         bsonType: [ "double" ],
         description: "must be a double and is required"
      }
   }
}

const data = {
   name: "Alice",
   year: 2019,
   major: "History",
   gpa: 3
}

ajv.validate(schema, data)
```

License: MIT

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