Validator Middleware
See original GitHub issueI have an idea, “Validator Middleware”.
I plan that I’ll make it with validator.js, which is used in express-validator. So, it will depend on the external library, which will be a “third-party” middleware.
The express middleware is helpful, but it’s a bit fat, and it seems not too easy to implement. And “just do porting” is not like Hono. I want to make the “Validator Middleware” simpler than the express middleware. Below is the synopsis that on my head now:
const app = new Hono()
app.use(
'/',
validator((v) => [
{
rule: v.isAlpha,
field: 'query',
name: 'q',
},
])
)
app.get('/', (c) => {
const res = validatorResult(c)
return c.json(res)
})
export default app
I’ll try to build it on github.com/honojs/validator
repository. So if it’s ready, please take a look!
Issue Analytics
- State:
- Created a year ago
- Comments:16 (9 by maintainers)
Top Results From Across the Web
Validation middlewares - express-validator
Creates a validation chain for one or more fields. ... Creates a middleware instance that will ensure at least one of the given...
Read more >express-json-validator-middleware - npm
An Express middleware to validate requests against JSON Schemas. Latest version: 3.0.1, last published: 7 months ago.
Read more >A Clean Approach to Using Express Validator
Express validator is one of the many npm packages for validating a ... as you may deem fit and then chain it with...
Read more >PayU/openapi-validator-middleware - GitHub
openapi-validator-middleware ... This package provides data validation within an Express, Koa or Fastify app according to a Swagger/OpenAPI definition. It uses ...
Read more >How to use Express Validator | Getting Started with Express ...
Express-validator is an express middleware that provides us with validation and sanitization functions. Actually, Express validator is built on top of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, AJV might be a good option, I would also check what library Fastify is using. I’m going on holiday soon, will be able to take a look into this in about week and a bit.
Hi there! especially @metrue and @usualoma .
I’m creating “Validator Middleware” and almost done:
https://github.com/honojs/validator/tree/develop
This is what I consider to be the Ideal API. I would like to go with this, but if you must have an opinion, please let me know.