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

add unknownutil validator #197

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ryoppippi
Copy link

@ryoppippi ryoppippi commented Oct 6, 2023

Hi!
I created a middleware of unknownutil (https://github.com/lambdalisue/deno-unknownutil)
This is kind of a zod or valibot, but so much faster and lighter!

@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2023

⚠️ No Changeset found

Latest commit: fd8b492

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ryoppippi ryoppippi force-pushed the feature/support-unknownutil-support branch from 8658faa to 255f7dd Compare October 6, 2023 17:02
@ryoppippi ryoppippi force-pushed the feature/support-unknownutil-support branch from 255f7dd to fd8b492 Compare October 6, 2023 21:47
@yusukebe
Copy link
Member

yusukebe commented Oct 7, 2023

Hi @ryoppippi !

Thanks for the PR. I didn't know unknownutil!

I'm curious about one thing. It seems to me that unknownutil only validates Types. So, in practice, it can only be used for "JSON". zod and valibot will validate the actual value. Examples, length of string, whether it is an email or not.

z.string().length(5);
z.string().email();

But unknownutil only handles Types. Honesty, I'm not a fan of calling it a Validator, what do you think?

@ryoppippi
Copy link
Author

ryoppippi commented Oct 7, 2023

Hi @yusukebe
Thank you for checking and reviewing my PR!!

As you mentioned, unknownutil validates only types. It is not a "data validator" but "type validator".
The bundle size is so tiny and it works really fast.

I'm a huge fan of Hono RPC.
Recently I've been using unknownutil with Hono for typing.
Although unknownutil lacks some features like length or email, It is quite useful for simple API.
For this purpose, I only need to type the input and check the type and keys. So data validation like zod or validot is too much for that purpose.

If you do not think this is a validator, I'll close this and create an independent repository.

PS: lizod is a similar type of validation library. This also only validates type

@ryoppippi
Copy link
Author

ryoppippi commented Oct 7, 2023

Here is the author of unknownutil commenting about whether it is a validator or not
icebob/validator-benchmark#7 (comment)

@yusukebe
Copy link
Member

Hi @ryoppippi,

Thanks for the explanation!

I understand well that unknownutil is not a data validator but a type validator. I also understand that you prefer to use unknownutil.

However, I would like to reject this PR, because most people imagine an actual data validator when they hear the word "Validator".

If you do not think this is a validator, I'll close this and create an independent repository.

When you create your repository, you can add the project to this page!

https://hono.dev/middleware/third-party

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.

None yet

2 participants