I want to convert these two strings into an object with key/value pair and being validated in zod:
{authors.allAuthors.map((author) => {
return (
<option key={author._id}>
{author.firstName} {author.lastName}
</option>
);
})}
And this is my schema entry for authors:
authors: z.string().transform((val) => JSON.parse(val))
My problem is that while doing so I'm receiving this error from the console:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length')
What to do?