seasonedcc / composable-functions

Types and functions to make composition easy and safe
MIT License
657 stars 13 forks source link

Decouple zod #114

Closed diogob closed 1 year ago

diogob commented 1 year ago

Decoupling from zod yields a clearer typing IMHO. It will also allow anyone to build adapters for any validator as long as they abide by zod's safeParseAsync and issues interface.

The long term goal is to track Zod's interface keeping this library always as our de facto standard parser. The additional burden on type maintenance should be minimal considering these interfaces have a small surface area and are quite fundamental to Zod's backwards compatibility.

TODO

diogob commented 1 year ago

@diogob now I realize that on objectSchema and undefinedSchema, in case of failure, it should return a Promise<ParserIssue[]> instead of throwing, as they are using a safe method: safeParseAsync

And we should also document it ;)

Great catch! I'm glad we never rush merges :P

gustavoguichard commented 1 year ago

I'm getting pretty excited about this PR tho

diogob commented 1 year ago

@gustavoguichard I have added a small note on the README, we can expand it with examples in future PRs. It seems we are ready to merge now.