buunguyen / koa-req-validator

Declarative request validation middleware for Koa
MIT License
19 stars 11 forks source link

Transfer koa context to validation rule method #8

Closed duylam closed 6 years ago

duylam commented 6 years ago

Validation rule method can do more thing by accessing full the request info

buunguyen commented 6 years ago

I suppose this could be useful some time, but I'm pretty concerned that this could be a breaking change. Is there a strong need for this? Example?

duylam commented 6 years ago

I'm pretty concerned that this could be a breaking change

I think it doesn't break others because the extra parameter is in last location

Is there a strong need for this? Example?

Yes, let's say a request wants to create an object Group but it requires the group name unique under current user tenant. So we want to validate whether the input groupd name on request body existed under the tenant or not. It requires the validation method to see who is on the request (on Authorization header or on a ctx.state.user populated by another middleware).

buunguyen commented 6 years ago

Please update README. Also bump semver to 1.0.0 because this is a breaking change (yes, it would be rare, but since this change the argument list of call sites, there's always a possibility of something gets broken.)

duylam commented 6 years ago

@buunguyen Thanks, addressed the comment