Custom Zod validator for MongoDB ObjectId.
npm install zod-mongodb-oid
const z = require('zod');
const { zObjectId } = require('zod-mongodb-oid');
const schema = z.object({
_id: zObjectId,
name: z.string(),
date: z.date(),
});
import z from 'zod';
import { zObjectId } from 'zod-mongodb-oid';
const schema = z.object({
_id: zObjectId,
name: z.string(),
date: z.date(),
});
import z from 'zod';
import { zObjectId } from 'zod-mongodb-oid';
const schema = z.object({
_id: zObjectId,
name: z.string(),
date: z.date(),
});