zod array still required?

Somehow following in my zod schema still requires my field
tags: z.string().array().nullish(),
tags: z.string().array().nullish(),
Submitting my form I still get
tags
:
message
:
"Expected array, received string"
tags
:
message
:
"Expected array, received string"
11 Replies
dan
dan3y ago
I’ve not used zod but I’d imagine “nullish” would mean it can be set to null. meaning a value is still required (string or null). .optional() would probably be what you want.
utdev
utdevOP3y ago
Did not work, the docs say following nullish is equivalent to
z.string().optional().nullable();
z.string().optional().nullable();
it worked on other fields which were only strings
dan
dan3y ago
"Expected array, received string" you're giving it a string when it wants an array. i didnt even read the error msg tbh
utdev
utdevOP3y ago
but it seems there is something different with an array? The thing is I am not giving it anything, let me double check to be sure nah not working strange
dan
dan3y ago
Check you're not passing in an empty string.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
utdev
utdevOP3y ago
Tried that still occurs 😢
awexis
awexis3y ago
What are you trying to have be nullish? the whole array or the values within? nvm i just read title
awexis
awexis3y ago
awexis
awexis3y ago
When I do this, this is the type i get, so that should be working. t3ggHeh
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server