0.2.0 • Published 8 years ago

alp-params-node v0.2.0

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

alp-params-node

import Koa from 'koa';
import params from 'alp-params-node';

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()

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago