8000 Support nested validation · Issue #14 · danneu/koa-bouncer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Support nested validation #14
Open
@danneu

Description

@danneu

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0