Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: typebox #368

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

lifeiscontent
Copy link
Contributor

@lifeiscontent lifeiscontent commented Dec 29, 2023

This PR introduces a new provider, TypeBox which is more than 4x smaller than Zod and fairly common in Node.js Projects for defining schemas

Not only is Typebox smaller and faster than Zod. It's also more popular.

https://npmtrends.com/@sinclair/typebox-vs-yup-vs-zod

@lifeiscontent lifeiscontent force-pushed the feat/typebox branch 5 times, most recently from 5625832 to 4039623 Compare December 30, 2023 00:23
@edmundhung
Copy link
Owner

Thanks for working on this! Although I think yup and zod are still more popular as jest depends on typebox internally and contributed most of the download counts for typebox, I am not against adding support to different solutions. But there are a few things I wanna learn more first.

  1. How do we add custom validation to typebox? For example, it's common to ask for the password twice in a signup form and validated whether both passwords match. How can we implement this using typebox?
  2. Does typebox support async validation? If yes, can we also support it in the integration?
  3. How does the coercion work and how does it handle empty string?

Really appreciate all the effort and I wish you a happy new year :)

@lifeiscontent
Copy link
Contributor Author

@edmundhung got some of your concerns answered, the password / confirm check would need to be integrated some how into some of the conform utils for typebox, if you have some thoughts, happy to take a stab at it, just let me know. :)

sinclairzx81/typebox#711 (reply in thread)

@edmundhung
Copy link
Owner

Thanks for getting me the answer! The APIs Typebox offered is indeed interesting and I feel like I can use some of the ideas to design the validitystate package going forward. But I want to get v1 out first (which hopefully happens in 1-2 weeks). I will get back to you on this once it is out.

@edmundhung
Copy link
Owner

Sorry for the wait! I will give it a try this week and see if I have any other concern before getting this merged. 🙌🏼

@aleshchynskyi
Copy link

👋 Just wanna bring a little attention to this PR.
Was thinking of adding conform to my project, but having two type validators doesn't sound attractive. Also I really like TypeBox, so many might benefit from this

@patlux
Copy link

patlux commented May 28, 2024

Any updates? :)

@stephen776
Copy link

+1 tools like Elysia in the bun world are using Typebox in the same manner that tRPC uses zod.

Would be nice to opt into typebox in cases where we are already using it elsewhere in the stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants