# joi-mongoose-objectid

> Joi extension to validate MongoDB objectId with mongoose

Latest version **2.0.1** (published 2020-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install joi-mongoose-objectid
pnpm add joi-mongoose-objectid
yarn add joi-mongoose-objectid
bun add joi-mongoose-objectid
```

## 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 | 2.0.1 |
| Published | 2020-04-28 |
| First published | 2020-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 2.3 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| Author | Florian Varrin |
| Maintainers | florian_varrin |

## Links

- npm: https://www.npmjs.com/package/joi-mongoose-objectid
- npm.io page: https://npm.io/package/joi-mongoose-objectid

## Dependencies (2)

- [mongoose](https://npm.io/package/mongoose.md) ^5.9.10
- [@hapi/joi](https://npm.io/package/@hapi/joi.md) ^17.1.1

## Recent versions

- 2.0.1 (latest) — 2020-04-28
- 2.0.0 — 2020-04-28
- 1.0.1 — 2020-04-27
- 1.0.0 — 2020-04-27

## README

# joi-mongoose-objectid

Joi extension to validate MongoDB objectId with mongoose

## use

`joi-mongoose-objectid` give you the `Joi.objectId()` function that validate the input with `mongoose.Types.ObjectId.isValid(value)`.

It is a Joi extension so you should extends Joi with it. Then you can extend Joi with other extensions.

```js
let Joi = require('@hapi/joi');
const joiObjectIdExtension = require('joi-mongoose-objectid');

Joi = Joi.extend((Joi) => joiObjectIdExtension);

const schema = Joi.object({
  id: Joi.objectId(),
  name: Joi.string().max(100),
  date: Joi.date()
});

schema.validate();

```

### Installation

```
npm install joi-mongoose-objectid
```

OR 

```
yarn add joi-mongoose-objectid
```

### Tests

There is two simple tests on the test.js file. One for success and one for failure. 
To run tests :  
```
npm run test
```

OR 

```
yarn test
```
## License

[MIT](https://github.com/mkg20001/joi-objectid/blob/master/LICENSE)

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