nokia / restful

A powerful RESTful framework for Go.
BSD 3-Clause "New" or "Revised" License
17 stars 14 forks source link

HTTP request validator #73

Closed Som-Som-CC closed 1 month ago

Som-Som-CC commented 1 month ago

Restful does not have any built-in validator at the moment. One may use https://github.com/go-validator/validator. And on any error return 422. But that needs redundant code pieces.

If you come from Python, e.g. using FastAPI and Pydantic Field, you may find that a feature badly missing. FastAPI has a different concept, though, as that generates OpenAPI Specification (OAS), too. Field descriptors act both as validator and OAS content.

Another option would be OAS as input, which could tag structs with validators. But an independent package could do that instead of pushing that to this one. Still, the validator must be invoked at some point.

Often an independent security gateway product provides content validation based on OAS. That is why this feature request is not highly important. Still, would be nice as an optional feature.