Closed jamelt closed 5 months ago
@jamelt I'm not opposed to supporting different validation libraries, though you are right I'd like to avoid hard dependencies with the core library. It would be fine to add packages that depend on other libraries that users can opt into and have the core work with an interface.
The main concern with this would be around how you continue to generate useful OpenAPI 3.1 / JSON Schema 2020-12 for the docs / CLI / SDKs. The Go Playground Validator is awesome and has some great validators, but you'd still want to generate the equivalent JSON Schema for the basic validators so clients know what the service expects. The other concern is making sure things remain efficient (see the benchmarks in adapters/humachi
for example).
BTW, I'm also not opposed to adding more validations to Huma, e.g. an alphanum:"true"
validation tag for a string
field might just be a shortcut for pattern:"^[a-zA-Z0-9]+$"
internally as a convenience for users to not have to remember or type the regex, and our regex validator can have more efficient implementations for some well-known common patterns. Edit: alternatively a lot of these could just be formats, like format:"hexadecimal"
or format:"rgba"
.
@danielgtaylor thanks for the feedback. I'll take a look at it. Right now I think what you ahve may suffice. Might be an easy way to drop a hook inthough.
Hey, thanks for the work you put together on this project. I really like where it's going.
I see that most of the validation here is designed to comply with the OpenAPI spec or something like that–I'm not super familiar with that.
I was curious if you would be open to integrating third-party validation support. For example, Go Playground Validator has many useful validations for the request input.
Would you be open to somehow integrating support for those validations into Huma?
Although I know that, to some degree, you want to limit dependencies, there's also possibly a way to integrate it via an interface or something like that.
But I want to know your thoughts before I attempt to build the integration.