Open
Description
koa-bouncer's main abstraction only works on top-level values in the query/body/param objects.
One idea for solving this without changing koa-bouncer much is to support some sort of dot notation: https://www.npmjs.com/package/dot-object
ctx.validateBody('user.password').validPassword()
ctx.validateBody('user.favoriteColors[]').isIn([red, orange, yellow, green, blue, violet])
Aside:
Due to its implementation, koa-bouncer's validators aren't generic and can't be reused beyond the Koa context object. So another idea is to reabstract the library so that it's more generic. For instance, using combinators.
Here's an idea I played with in another project: https://github.com/danneu/klobb#validation
Though were I to ever reabstract koa-bouncer, I would just create a new library rather than inconveniencing anyone that uses koa-bouncer.
Just some ideas.
Metadata
Metadata
Assignees
Labels
No labels