schematron
v0.2.1
Published
Yet another schema validation library, including Connect/Express middlewares
Downloads
7
Readme
Yet another boilerplate free schema validation library, Connect/Express middleware included.
{validate, any, optional} = require 'schematron'
schema = {
key: any
count: Number
isActive: Boolean
name: optional(String)
}
data = {
key: {}
count: 2
isActive: false
}
{errors, data} = validate(schema, data)
Or use Connect/Express middleware
{validate} = require 'schematron/middleware'
app.get '/search',
validate(q: String, limit: optional(Number)),
(req, res) ->
// access req.validQuery for validated data