Elegant, highly efficient data validation for JavaScript
Overview
- Provides concise, performant, readable, data and type validation for JavaScript apps, using built-in and user-defined data-validating pseudo types.
- Improves application efficiency and readability by unifying the most basic but common data and type validations in JavaScript apps, into single, concise, highly optimized operations.
- Employs bitwise operations, data pre-processing, and memory-efficient memoization for fast, robust performance in small and large apps and libraries.
- Ready for nodejs, requirejs, and regular script tag.
- Website – xtype.js.org
Go from this:
{ if typeof value === 'string' if valuelength > 1 return EmployeeDB; else if valuelength === 1 return EmployeeDB; else return error: 'Invalid search value supplied' ; else if typeof value === 'object' && value !== null if Objectlength === 1 return EmployeeDB; else if Objectlength > 1 return error: 'Search by multiple fields not supported' ; else return error: 'Invalid search value supplied' ; else if typeof value === 'number' if ! && && value > 0 && value % 1 === 0 return EmployeeDB; else return error: 'Invalid employee number supplied' ; else if typeof value === 'undefined' || value === null return error: 'No search value supplied' ; else return error: 'Invalid search value supplied' ; }
To concise, performant, readable, data validation:
{ }
And even add custom validation types of your own:
xtypeext; { }
Links
Installation
See here.
Dependencies
None.
Build / Test
See here.
License
MIT license.
Website
Visit the website for usage guide, examples, API docs, and installation.