1.0.0-alpha • Published 7 years ago

caffe-validate v1.0.0-alpha

Weekly downloads
7
License
MIT
Repository
github
Last release
7 years ago

Caffe Validation

The official validation library for building opinionated, Caffe applications. This library is built on top of the joi. It offers validation support for both query string parameters and the request body (input). This library does not yet offer support for file-based validation.

Getting Started

Install via npm:

npm install --save caffe-validate

Example Usage

Create a NodeJS server using the contents below, then launch the application and go to https://localhost:5000 in your browser. Feel free to add the name key as a query string value to print your name instead of the default "World".

Example: https://localhost:5000?name=JohnSmith

var caffe     = require("caffe");
var validate  = require("caffe-validate");

var app = caffe.brew([
  validate.query(is => {
    name: is.string().default("World"),
  }),
  caffe.text(200, (ctx) => `Hello, ${ctx.query.name}`),
]);

caffe.serve(app, 5000);

Documentation

Coming soon.