Package Exports
- @zenweb/validation
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@zenweb/validation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
zenweb-validation
zenweb validation module
Quick start
$ npm i @zenweb/validation
app.js
'use strict';
const app = module.exports = require('zenweb').create();
app.setup('@zenweb/validation');
app.start();
app/controller/simple.js
const app = require('../../app');
app.router.post('/simple', ctx => {
ctx.validate('simple'); // default data: ctx.request.body
ctx.body = 'ok';
});
app/validation/simple.schema.json
{
"type": "object",
"properties": {
"foo": { "type": "number", "minimum": 0 },
"bar": { "type": "string", "maxLength": 10, "minLength": 2 }
},
"required": ["foo", "bar"],
"additionalProperties": false
}