Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

credible

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

credible

Unopinionated validation framework for node and the browser.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-72.73%
Maintainers
1
Weekly downloads
 
Created
Source

credible

Credible is a library for validating objects in node.js or the browser. While it provides several validators out of the box, credible is very unopinionated; mostly, credible simply provides a framework for object validation.

Installation

Credible has two dependencies:

  • underscore.js or lodash
  • An A+ promise library, a la bluebird or when.js

Node.js

$ npm install credible --save

Browser

<script src="/lodash.js"></script>
<script src="/bluebird.js"></script>
<script src="/credible.js"></script>

Example

var person = {
  firstName: 'Noah',
  lastName: 'Portes Chaikin'
}

var credible = new Credible({
  firstName: 'alpha'
  lastName: 'alpha'
});

credible.run(person)
  .catch(function(err) {
    console.log(err);
  })

API

var rulesObject = {
  username: 'alpha',
  email: ['presence', 'email']
}

new Credible(rulesObject);

The most straightforward and "built to order" way to get started is by passing an object to the Credible constructor with the properties you'd like to validate and the rules you'd like to validate the property against.

Rules can either reference a native validator or be a function:

var rulesObject = {
  username: 'alpha',
  email: function (model, attribute) {
    if (!email) throw 'No e-mail provided'
  }
}

new Credible(rulesObject);

Credible.validate() returns a chainable object.

var credible = new Credible()
credible.validate('');

To Do

  • Write tests
  • Finish this documentation

Keywords

FAQs

Package last updated on 23 Jan 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc