Skip to content

Latest commit

 

History

History
53 lines (39 loc) · 779 Bytes

File metadata and controls

53 lines (39 loc) · 779 Bytes

zod-mongodb-oid

Custom Zod validator for MongoDB ObjectId.

Install

npm install zod-mongodb-oid

CommonJS Usage

const z = require('zod');
const { zObjectId } = require('zod-mongodb-oid');

const schema = z.object({
  _id: zObjectId,
  name: z.string(),
  date: z.date(),
});

ESM Usage

import z from 'zod';
import { zObjectId } from 'zod-mongodb-oid';

const schema = z.object({
  _id: zObjectId,
  name: z.string(),
  date: z.date(),
});

TS Usage

import z from 'zod';
import { zObjectId } from 'zod-mongodb-oid';

const schema = z.object({
  _id: zObjectId,
  name: z.string(),
  date: z.date(),
});

Related Packages