An extremely fast and Joi like data validator. It shares the Joi schema creation syntax but it's much, much faster.
npm install fast-validator varfast=require('fast-validator');varrules=fast.string().min(2).max(50);vardata='fast-validator';if(rules.validate(data)){console.log('Valid data!');}else{console.log('Invalid data');}- No input sanitization: Because the main methods
validateandvalidateListreturn 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
truewhen the data is validated sucessfully orfalsewhen it is not.
Validating a simple object with strings and numbers one million times is x500 faster than Joi.
varfastSchema=fast.object().keys({a:fast.string().min(2).max(50),b: fast.number().min(2).max(50)});varjoiSchema=Joi.object().keys({a:Joi.string().min(2).max(50),b: Joi.number().min(2).max(50)});vardata={a: 'alex',b: 5};fastSchema.validate(data);// 1,000,000 runs -> 110msJoi.validate(data,joiSchema);// 1,000,000 runs -> 55,000msCheck examples folder!