Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

match rule does not exist #10

@dwang68

Description

@dwang68

I am trying to use the match rule to validate my http headers. I am using koa-validation 0.1.9, and node version 7.8.0
Here is how I used koa-validation in my code:

`this.app.use(function* (next) {
yield this.validateHeaders({
'content-type': { required: [], match: ['application/json'] },
accept: { required: [], match: ['application/json'] },
});

  if (this.validationErrors) {
    this.status = 422;
    this.body = this.validationErrors;
  } else {
    this.status = 201;
    this.body = { created: true };
  }
});

`
However, when I send the following request, i got an error saying the match rule does not exist.

{ method: 'GET', url: '/event/v1/ping', header: { 'cache-control': 'no-cache', 'postman-token': 'a64c568b-f549-4b85-901a-9f41502f5021', 'content-type': 'application/json', accept: 'application/json', 'user-agent': 'PostmanRuntime/3.0.11-hotfix.2', host: 'localhost:6080', 'accept-encoding': 'gzip, deflate', connection: 'keep-alive' } }
I am wondering if I did something wrong or this is a bug. Thanks.

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