auk-params

2.0.0 • Public • Published

auk-params

import Koa from 'koa';
import params from 'auk-params';
 
const app = new Koa();
params(app);
    index(ctx) {
        const name = ctx.params.string('name').notEmpty().value;
        ctx.body = this.t('Hello %s!', ctx.params.isValid() ? name : 'World');
    },
 
    something(ctx) {
        // throw a 404 if the param was not found
        const name = ctx.validParams.string('name').notEmpty().value;
        ctx.body = this.t('Hello %s!', name);
    },

Validator

.isValid()

.hasErrors()

.getErrors()

.string(name, position)

ValueStringValidator

.notEmpty()

Readme

Keywords

Package Sidebar

Install

npm i auk-params

Weekly Downloads

2

Version

2.0.0

License

ISC

Last publish

Collaborators

  • churpeau