0.0.3 • Published 3 years ago

koa-verifier v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

koa-verifier

Description

The koa-parameter refactored by Typescript, and some changes have been made in the way it is used.

Original warehouse: https://github.com/koajs/parameter

Usage

npm install koa-verifier --save

If you need perfect syntax hints, you can choose to install these two dependencies:

npm i @types/koa @types/parameter --save-dev

In the entry file of your application:

import Koa from 'koa'
import Verifier from 'koa-verifier'

const app = new Koa()
app.use(Verifier.register())

In a controller:

import Verifier from 'koa-verifier'
import { Context } from 'koa'

class ExampleCtrl {
  test(ctx: Context): void {
    Verifier.validate(ctx, {
      name: { type: 'string', required: true },
      age: { type: 'number', required: false }
    })
    // do something...
  }
}

About the translate and rules

You can checkout koa-parameter to see how to use translate.

You can checkout parameter to get all the rules.

License

MIT

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago