middleware icon indicating copy to clipboard operation
middleware copied to clipboard

add unknownutil validator

Open ryoppippi opened this issue 2 years ago • 5 comments

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!

ryoppippi avatar Oct 06 '23 15:10 ryoppippi

⚠️ No Changeset found

Latest commit: fd8b4921b4aa47de0e1713408d567a9a78d8106c

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

changeset-bot[bot] avatar Oct 06 '23 15:10 changeset-bot[bot]

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?

yusukebe avatar Oct 07 '23 00:10 yusukebe

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 avatar Oct 07 '23 09:10 ryoppippi

Here is the author of unknownutil commenting about whether it is a validator or not https://github.com/icebob/validator-benchmark/pull/7#issuecomment-1751182584

ryoppippi avatar Oct 07 '23 09:10 ryoppippi

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

yusukebe avatar Oct 11 '23 10:10 yusukebe

@yusukebe So you can close this issue Cheers

ryoppippi avatar Jun 18 '24 18:06 ryoppippi

@ryoppippi

Okay! Cheers.

yusukebe avatar Jun 18 '24 18:06 yusukebe