Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A cross-browser / node.js validator used by resourceful and flatiron
JavaScript
tag: v0.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
lib
test
.gitignore
LICENSE
README.md
package.json

README.md

revalidator

A cross-browser / node.js validator used by resourceful and flatiron.

Example

The core of revalidator is simple and succinct: revalidator.validate(obj, schema):

  var revalidator = require('revalidator');

  console.dir(revalidator.validate(someObject, {
    properties: {
      url: {
        description: 'the url the object should be stored at',
        type: 'string',
        pattern: '^/[^#%&*{}\\:<>?\/+]+$',
        required: true
      },
      challenge: {
        description: 'a means of protecting data (insufficient for production, used as example)',
        type: 'string',
        minLength: 5
      },
      body: {
        description: 'what to store at the url',
        type: 'any',
        default: null
      }
    }
  });

This will return with a value indicating if the obj conforms to the schema. If it does not, a descriptive object will be returned containing the errors encountered with validation.

  {
    valid: true // or false
    errors: [/* Array of errors if valid is false */]
  }

In the browser, the validation function is exposed on window.validate by simply including revalidator.js.

Installation

Installing npm (node package manager)

  $ curl http://npmjs.org/install.sh | sh

Installing revalidator

  $ [sudo] npm install revalidator

Tests

All tests are written with vows and should be run with npm:

  $ npm test

Author: Charlie Robbins, Alexis Sellier

Contributors: Fedor Indutny, Bradley Meck, Laurie Harper

License: Apache 2.0

Something went wrong with that request. Please try again.