shellscape / jsx-email

Build emails with a delightful DX
https://jsx.email
MIT License
897 stars 28 forks source link

Add `zod` and `yup` support for creating default props #134

Closed shellscape closed 4 months ago

shellscape commented 6 months ago

As much as I loathe zod, this needs to be done.

This is a placeholder issue for a task for jsx-email v1.6.0

CanRau commented 5 months ago

Just in case throwing in here that I like (& use) valibot a lot. Not sure how the current TemplateStruct works under the hood but probably a good idea to make it general so you can use whatever

shellscape commented 5 months ago

That's interesting. valibot looks like an implementation copy of superstruct (which is what the TemplateStruct thing was initially about)

I haven't begun development on this yet, still thinking through implementation and if it even makes sense to have builtin support for various validation schema types. You can however, set PreviewProps however you'd like to now, including with valibot, and that won't change.

CanRau commented 5 months ago

How would I currently use valibot, isn't it running superstructs create behind the scenes or did I get your comment wrong?

1 option could be keeping the current behavior but if TemplateStruct (maybe with a different name) is set to a function just run that with some context data so within that function people can do what they want, but would be more boilerplate and also type inference will be harder, maybe via a generic.

I'm on my phone right now 😅

shellscape commented 4 months ago

Have been playing with this idea a lot and the one thing that I've been struggling with is where the value is added - there's no real advantage to having builtin support for any validator libraries. There's no real time savings for the user, and there's no real complexity savings either. If anything, it potentially makes the templates more complex.

At the moment, we're going to remove the builtin superstruct support for the next major version, and table the idea for the meantime.