UNPKG

apeman-app-validate

Version:
45 lines (41 loc) 927 B
/** This is an example Apemanfile to use apeman-app-validate */ 'use strict' // Define JSON schema for validation. const userCreateSchema = { properties: { account_name: { type: 'string', minLength: 2 } }, required: [ 'account_name' ] } module.exports = { $pkg: { /* ... */ }, $apps: { // Define your own app. 'my-app-01': { // Map url and handlers. '/': [ require('apeman-app-json')(), require('apeman-app-form')(), require('apeman-app-route')({ '/user': { 'POST': [ // Add routing function. // Serve error if validation failed. require('apeman-app-validate')(userCreateSchema, { // Options }), function doCreateUser (req, res, next) { /* ... */ } ] } }) ] } } }