Using zod to generate table schema #265
-
Hey mswjs/data team, I'm wondering if you have any plan to bring zod validation into table :) Something like this. const PostSchema = {
dto: z.object({
id: z.string().uuid().describe('primaryKey'),
title: z.string(),
body: z.string().optional().nullable()
})
}
const PostTable = generateTable(PostSchema.dto) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey, @salehi-hassan. There is no support for using Zod as the source of truth for the schema. We use our own schema format, although it concerns itself with the data shape without any data type validation on top. Frankly, I'm not sure how feasible it'd be to support Zod given that schema format difference. The logic of Data is rooted in the fixed model definition, property proxies that enable relationships, and a few other things specific to Data that Zod won't have. As of now, I would not consider this as a support candidate but you are welcome to pursue adapters between Zod/Data to make things work. |
Beta Was this translation helpful? Give feedback.
Hey, @salehi-hassan.
There is no support for using Zod as the source of truth for the schema. We use our own schema format, although it concerns itself with the data shape without any data type validation on top.
Frankly, I'm not sure how feasible it'd be to support Zod given that schema format difference. The logic of Data is rooted in the fixed model definition, property proxies that enable relationships, and a few other things specific to Data that Zod won't have. As of now, I would not consider this as a support candidate but you are welcome to pursue adapters between Zod/Data to make things work.