node package manager


modular specs compilation framework


specs is a modular framework to compile specification models into javascript functions.

npm install specs
var assert = require('assert');
var specs = require('specs');

var engine = specs.engine();

var spec = engine.compile({
  foo: 42,
  bar: /foo+bar/

  foo: 42,
  bar: 'foooooooobar'

Directives allow you to extend the grammar of your specification engine

engine.directive('lt', function (model) {
  return function (x) { return x < model; };

and use them in specification models

var spec = engine.compile({ $lt: 43 });


A module is a set of directives.

You can write your own modules or reuse existing ones.

Below are officially supported modules to come

  • specs-comp : basic scalar comparison operators
  • specs-logic : basic logic operators
  • specs-list : basic list operators (contains, any, none of, ...)

Module usage is then like so

var engine = specs.engine('comp', 'logic', 'list');