GithubHelp home page GithubHelp logo

alemures / fast-validator Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 460 KB

An extremely fast and Joi like data validator

JavaScript 100.00%
joy sanitization validation fast performance schema nodejs

fast-validator's Introduction

fast-validator

An extremely fast and Joi like data validator. It shares the Joi schema creation syntax but it's much, much faster.

Install

npm install fast-validator

Usage

var fast = require('fast-validator');

var rules = fast.string().min(2).max(50);
var data = 'fast-validator';

if (rules.validate(data)) {
  console.log('Valid data!');
} else {
  console.log('Invalid data');
}

Limitations

  • No input sanitization: Because the main methods validate and validateList return a single boolean, fast-validator is not able to sanitize data like Joi (with the method any#strip for example).
  • No descriptive validations: In the event of wrong validation it only returns a true when the data is validated sucessfully or false when it is not.

Benchmarks

Validating a simple object with strings and numbers one million times is x500 faster than Joi.

var fastSchema = fast.object().keys({ a:fast.string().min(2).max(50), b: fast.number().min(2).max(50) });
var joiSchema = Joi.object().keys({ a:Joi.string().min(2).max(50), b: Joi.number().min(2).max(50) });
var data = { a: 'alex', b: 5 };

fastSchema.validate(data); // 1,000,000 runs -> 110ms
Joi.validate(data, joiSchema); // 1,000,000 runs -> 55,000ms

Check examples folder!

jsdoc

http://alemures.github.io/fast-validator/

fast-validator's People

Contributors

alemures avatar

Stargazers

 avatar

Watchers

 avatar

fast-validator's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.