-
-
Notifications
You must be signed in to change notification settings - Fork 113
fix date string zod validation #355
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
Conversation
@@ -114,7 +114,7 @@ export default class Transformer { | |||
} else if (inputType.type === 'Boolean') { | |||
result.push(this.wrapWithZodValidators('z.boolean()', field, inputType)); | |||
} else if (inputType.type === 'DateTime') { | |||
result.push(this.wrapWithZodValidators('z.date()', field, inputType)); | |||
result.push(this.wrapWithZodValidators('z.union([z.date(), z.string().datetime()])', field, inputType)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for working on this @Xemah !
I tried it out, and there's a problem with the distribution of union
over array
:
Here the inferred type doesn't conform to Prisma filter's typing. The union
needs to wrap around array
. Maybe we should refactor wrapWithZodValidators
and and pass in a list of validators so we can deal with the array distribution inside of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, we have to do like if its a union, then use '.array()' for each of the rule inside union
Like if it's z.union([z.date(), z.string().datetime()])
, it should do z.union([z.date().array(), z.string().datetime().array()])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so.
No description provided.