3.2.0 • Published 4 months ago

@parameter1/mongodb-prop-types v3.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

MongoDB Prop Types

Common prop type validators using Joi.

Installation

yarn add @parameter1/mongodb-prop-types

Usage

Prop type schemas.

import { mongoClientProp, mongoCollectionProp, mongoSessionProp } from '@parameter1/mongodb-prop-types';

import { MongoClient } from '@parameter1/mongodb-core';
import Joi from 'joi';

const { attempt } = Joi

const client = new MongoClient('mongodb://some-server:27071');

// valid
attempt(client, mongoClientProp.required());
attempt(client.db('test').collection('foo'), mongoCollectionProp.required());
attempt(client.startSession(), mongoSessionProp.required());

Extending Joi to add objectId type.

import Joi from 'joi';
import { objectIdType } from '@parameter1/mongodb-prop-types';

Joi.extend(objectIdType);

const someObjectId = new ObjectId();

// valid
attempt(someObjectId, Joi.objectId().required());
3.2.0

4 months ago

3.1.0

7 months ago

3.0.0

8 months ago

2.3.0

9 months ago

2.2.0

11 months ago

2.0.2

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago

1.4.0

1 year ago

2.0.0

1 year ago

1.2.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.1.0

1 year ago

1.0.0

2 years ago