# joi-mongodb-oid

> Custom Joi validator for MongoDB ObjectId.

Latest version **2.0.6** (published 2023-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install joi-mongodb-oid
pnpm add joi-mongodb-oid
yarn add joi-mongodb-oid
bun add joi-mongodb-oid
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2023-04-22 |
| First published | 2023-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Paul Smith |
| Maintainers | merlin4 |
| Keywords | joi, mongodb, objectid, oid, custom, validator, extension, plugin, inject |

## Links

- npm: https://www.npmjs.com/package/joi-mongodb-oid
- Repository: https://github.com/paulsmithkc/express-packages
- Homepage: https://github.com/paulsmithkc/express-packages/tree/main/packages/joi-mongodb-oid#readme
- Issues: https://github.com/paulsmithkc/express-packages/issues
- npm.io page: https://npm.io/package/joi-mongodb-oid

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 2.0.6 (latest) — 2023-04-22
- 2.0.5 — 2023-04-22
- 2.0.4 — 2023-04-16
- 2.0.3 — 2023-04-10
- 2.0.2 — 2023-04-10

## README

# joi-mongodb-oid

Custom Joi validator for MongoDB ObjectId.

## Install

```bash
npm install joi-mongodb-oid
```

## CommonJS Usage

In your application's entry point (index.js/server.js/app.js):

```js
const Joi = require('joi-mongodb-oid')();
```

Then the `objectId()` validator can be used just like any other Joi validator:

```js
const schema = Joi.object({
  _id: Joi.objectId(),
  name: Joi.string(),
  date: Joi.date(),
});
```

## ESM Usage

In your application's entry point (index.js/server.js/app.js):

```js
import JoiMongoDB from 'joi-mongodb-oid';
const Joi = JoiMongoDB();
```

Then the `objectId()` validator can be used just like any other Joi validator:

```js
const schema = Joi.object({
  _id: Joi.objectId(),
  name: Joi.string(),
  date: Joi.date(),
});
```

## TS Usage

Inject the objectId validator:

```js
import JoiMongoDB from 'joi-mongodb-oid';
const Joi = JoiMongoDB();
```

Then the `objectId()` validator can be used just like any other Joi validator:

```js
const schema = Joi.object({
  _id: Joi.objectId(),
  name: Joi.string(),
  date: Joi.date(),
});
```

## Similar Packages

- [joi-objectid](https://www.npmjs.com/package/joi-objectid)
- [joi-oid](https://www.npmjs.com/package/joi-oid)
- [joi-objectid-validator](https://www.npmjs.com/package/joi-objectid-validator)
- [joi-mongodb-objectid](https://www.npmjs.com/package/joi-mongodb-objectid)
- [joi-mongoose-objectid](https://www.npmjs.com/package/joi-mongoose-objectid)
- [joi-objectid-extension](https://www.npmjs.com/package/joi-objectid-extension)
- [object-id-joi-extension](https://www.npmjs.com/package/object-id-joi-extension)

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