Socket
Socket
Sign inDemoInstall

revalidator

Package Overview
Dependencies
0
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    revalidator

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


Version published
Maintainers
3
Install size
43.2 kB
Created

Readme

Source

revalidator Build Status

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

FAQs

Last updated on 16 Apr 2012

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc