You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Another sort of inconvenience with koa-bouncer is that sometimes you want to apply the same validation rules for multiple fields, and it leads to a lot of duplicate code. It would be cool if you could do that easily.
agreed. best you can do for reuse in koa-bouncer is to create a custom validator method that calls other validator methods which isn't a very good solution for ad-hoc reuse.
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
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.
The text was updated successfully, but these errors were encountered: