-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
fix(zod): date format now respects useDates override #1406
Conversation
Looks like tests are failing with...
|
@melloware Yep already on it, didn't run the generated locally as I didn't know they existed aha |
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.
thank you(and I'm so sorry)
packages/zod/src/index.ts
Outdated
if (!context.output.override.useDates) { | ||
functions.push([type as string, undefined]); | ||
} | ||
functions.push(['date', undefined]); | ||
break; | ||
} | ||
|
||
functions.push([type as string, undefined]); | ||
|
||
if (schema.format === 'date-time') { | ||
functions.push(['datetime', undefined]); | ||
if (!context.output.override.useDates) { | ||
functions.push([type as string, undefined], ['datetime', undefined]); | ||
} else { | ||
functions.push(['date', undefined]); | ||
} | ||
break; | ||
} | ||
|
||
functions.push([type as string, undefined]); | ||
|
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.
looks good to me.
and if i had to say, it can makes this simple to handle useDates
first like:
if (
context.output.override.useDates &&
(schema.format === 'date' || schema.format === 'date-time')
) {
functions.push(['date', undefined]);
break;
}
functions.push([type as string, undefined]);
if (schema.format === 'date') {
functions.push(['date', undefined]);
break;
}
if (schema.format === 'date-time') {
functions.push(['datetime', undefined]);
break;
}
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.
See comments from @RyoNkmr
@melloware @RyoNkmr This should be ready for re-review, all the tests now pass and the requested changes were made. |
Status
READY
Description
This PR fixes #1402 and respects the
useDates
override when generating the zod specification.