-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add utilities for creating optional types #10
Comments
This is easily achieved by making users of the lib use the const User = z.object({
id: z.string().uuid().default(crypto.randomUUID),
created: z
.string()
.datetime()
.default(() => new Date().toISOString()),
}); or if they prefer to use timestamps: const User = z.object({
id: z.string().uuid().default(crypto.randomUUID),
created: z
.number()
.int()
.default(() => Date.now()),
}); |
@jnssnmrcs Yeah you're completely right, thus it's marked as good first issue :D The reason we would want some wrapper function is that we would be able to get IntelliSense for instance for flags such as "primary key" and "indexed key" and "unique", because having |
i don't if this is an existing solution or just an idea but as I'm using v0.1.1 so i'm leaving this here. Leem know if it doesn't belong here and i'll create a new issue about it. I have this user table(as seen below), the export const User = z.object({
id: z.number().describe("primary, unique"),
username: z.string().describe("unique").optional(),
firstName: z.string(),
lastName: z.string().optional(),
enableOptions: z.boolean().default(false).optional(),
createdAt: z.date(),
updatedAt: z.date().nullable(),
}); |
This has been fixed in main branch but I don't think it has been released yet, so in the next release zod default values should work. |
Okay, thanks! |
In the same way as in Prisma we have
createdAt DateTime @default(now())
,we should have in Pentagon something along the lines of:
The text was updated successfully, but these errors were encountered: