Menu

1 / 8

I got tired of translating Zod errors. So I built friendly-zod.

DEV Community·Collins Mbathi·6 months ago
#jojua83t
#typescript#javascript#webdev#email#friendly
Reading 0:00
15s threshold

If you've shipped a form with Zod, you've written this code at least once:

const result = Schema . safeParse ( input ); if ( ! result . success ) { const errors = result . error . issues . reduce (( acc , issue ) => { acc [ issue . path . join ( " . " )] = issue . message ; return acc ; }, {} as Record < string , string > ); }

Enter fullscreen mode

Exit fullscreen mode

And then you've stared at "Invalid string: expected email" next to a form field and thought: no real user should ever see this.

That tiny translation layer — between what Zod gives you and what your UI actually needs — ends up in every project. So I packaged it.

It's called friendly-zod .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.