import zodToMongoSchema from 'zod-to-mongodb-schema';
const zodObjectId = z.custom<ObjectId | string>(value => ObjectId.isValid(value));
const userSchema = z.object({
_id: zodObjectId,
name: z.string().min(3),
dateOfBirth: z.date(),
});
const mongoUserSchema = zodToMongoSchema(userSchema, { zodObjectId });
error:'ZodObject' not supported.
"zod-to-mongodb-schema": "^0.0.1"
import zodToMongoSchema from 'zod-to-mongodb-schema';
const zodObjectId = z.custom<ObjectId | string>(value => ObjectId.isValid(value));
const userSchema = z.object({
_id: zodObjectId,
name: z.string().min(3),
dateOfBirth: z.date(),
});
const mongoUserSchema = zodToMongoSchema(userSchema, { zodObjectId });
error:'ZodObject' not supported.