Skip to content

Commit

Permalink
add tests and docs for z.string().date()
Browse files Browse the repository at this point in the history
  • Loading branch information
AGalabov committed Dec 6, 2024
1 parent f7b70c3 commit 58e9213
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ The list of all supported types as of now is:
- `.cuid2()`
- `.ulid()`
- `.ip()`
- `.date()`
- `.datetime()`
- `.uuid()`
- `.email()`
Expand Down
1 change: 1 addition & 0 deletions spec/types/string.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('string', () => {
${'uuid'} | ${z.string().uuid()} | ${'uuid'}
${'email'} | ${z.string().email()} | ${'email'}
${'url'} | ${z.string().url()} | ${'uri'}
${'date'} | ${z.string().date()} | ${'date'}
${'datetime'} | ${z.string().datetime()} | ${'date-time'}
`(
'maps a ZodString $format to $expected format',
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export class StringTransformer {
if (zodString.isUUID) return 'uuid';
if (zodString.isEmail) return 'email';
if (zodString.isURL) return 'uri';
if (zodString.isDate) return 'date';
if (zodString.isDatetime) return 'date-time';
if (zodString.isCUID) return 'cuid';
if (zodString.isCUID2) return 'cuid2';
if (zodString.isULID) return 'ulid';
if (zodString.isIP) return 'ip';
if (zodString.isEmoji) return 'emoji';
if (zodString.isDate) return 'date';

return undefined;
}
Expand Down

0 comments on commit 58e9213

Please sign in to comment.