Skip to content

How to check for dayjs type with zod? #1259

Answered by dvakatsiienko
anthonyma94 asked this question in Q&A
Discussion options

You must be logged in to vote

The solution didn't worked for me causing an error.

Cannot read properties of undefined (reading 'name')
TypeError: Cannot read properties of undefined (reading 'name') at Object.instanceOfType [as instanceof] (webpack-internal:///./node_modules/zod/lib/index.mjs:3065:43)

But this works:

import dayjs, { type Dayjs } from 'dayjs';

...

z.instanceof(dayjs as unknown as typeof Dayjs)

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@jhigdon
Comment options

@aki-caffeine
Comment options

@almogzur
Comment options

Answer selected by anthonyma94
Comment options

You must be logged in to vote
1 reply
@Zain-Bin-Arshad
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants