cloudflare / chanfana

OpenAPI 3 and 3.1 schema generator and validator for Hono, itty-router and more!
https://chanfana.pages.dev
MIT License
288 stars 38 forks source link

Support for minLength / maxLength strings #55

Closed gimenete closed 1 year ago

gimenete commented 1 year ago

It'd be great to have support for minLength and maxLength.

Specially when you have a limit for a column in the database, it'd be nice to have the API to limit the value already and not have to do it manually inside the endpoint implementation.

This would also be useful for checking that a value is not an empty string by using minLength: 1, which is pretty common, I think.

G4brym commented 1 year ago

Hey @gimenete, i'm planning on deprecating the current types and replacing it with zod, then all these field parameters like what you are asking will became available What do you think of this change to mainly use zod as definition and validation?

gimenete commented 1 year ago

@G4brym that'd be awesome. In fact I'm already using zod and from it I generate the open api types. See my comment here https://github.com/cloudflare/itty-router-openapi/issues/47#issuecomment-1531180686

So using zod directly would be much simpler!

G4brym commented 1 year ago

yeah, your commant was what started an internal discussion to just use zod directly

arjunyel commented 1 year ago

@G4brym hi friend, is there any chance of instead of just using Zod make it pluggable? Personally I would like to use ArkType :) https://arktype.io/

rhutikcodes commented 1 year ago

any updates on this? Zod will be super useful :)

G4brym commented 1 year ago

Hey there, i've just published the new v1.0.0 release that adds Zod support everywhere Learn more here