All Projects → lucono → Xtypejs

lucono / Xtypejs

Licence: mit
Elegant, highly efficient data validation for JavaScript.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Xtypejs

Rdfunit
An RDF Unit Testing Suite
Stars: ✭ 117 (-67.23%)
Mutual labels:  data-validation
check-engine
Data validation library for PySpark 3.0.0
Stars: ✭ 29 (-91.88%)
Mutual labels:  data-validation
data-validator
A tool to validate data built around Apache Spark.
Stars: ✭ 66 (-81.51%)
Mutual labels:  data-validation
Data Cleaning 101
Data Cleaning Libraries with Python
Stars: ✭ 243 (-31.93%)
Mutual labels:  data-validation
form-binder
A micro data binding and validating framework, very easy to use and hack
Stars: ✭ 18 (-94.96%)
Mutual labels:  data-validation
pyvaru
Rule based data validation library for python 3.
Stars: ✭ 17 (-95.24%)
Mutual labels:  data-validation
React Jsonschema Form
A React component for building Web forms from JSON Schema.
Stars: ✭ 10,870 (+2944.82%)
Mutual labels:  data-validation
Laravel Recaptcha
Google ReCaptcha package for Laravel
Stars: ✭ 273 (-23.53%)
Mutual labels:  data-validation
IATI.cloud
The open-source IATI datastore for IATI data with RESTful web API providing XML, JSON, CSV output. It extracts and parses IATI XML files referenced in the IATI Registry and powered by Apache Solr.
Stars: ✭ 35 (-90.2%)
Mutual labels:  data-validation
changeset
(unreleased) Data validation with first-class and first-order labels in OCaml
Stars: ✭ 28 (-92.16%)
Mutual labels:  data-validation
Dry Schema
Coercion and validation for data structures
Stars: ✭ 249 (-30.25%)
Mutual labels:  data-validation
objectiv-analytics
Powerful product analytics for data teams, with full control over data & models.
Stars: ✭ 399 (+11.76%)
Mutual labels:  data-validation
form-binder-java
Java port of form-binder, a micro data binding and validating framework
Stars: ✭ 29 (-91.88%)
Mutual labels:  data-validation
Cerberus
Lightweight, extensible data validation library for Python
Stars: ✭ 2,640 (+639.5%)
Mutual labels:  data-validation
validada
Another library for defensive data analysis.
Stars: ✭ 29 (-91.88%)
Mutual labels:  data-validation
Typical
Typical: Fast, simple, & correct data-validation using Python 3 typing.
Stars: ✭ 111 (-68.91%)
Mutual labels:  data-validation
deepchecks
Test Suites for Validating ML Models & Data. Deepchecks is a Python package for comprehensively validating your machine learning models and data with minimal effort.
Stars: ✭ 1,595 (+346.78%)
Mutual labels:  data-validation
Openapi Cop
A proxy that validates responses and requests against an OpenAPI document.
Stars: ✭ 338 (-5.32%)
Mutual labels:  data-validation
Validus
A dead simple Python string validation library.
Stars: ✭ 257 (-28.01%)
Mutual labels:  data-validation
validation-components
A collection of common validation predicates for ValidationToolkit framework
Stars: ✭ 26 (-92.72%)
Mutual labels:  data-validation

xtypejs Logo

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:

function searchEmployees(value) {
    if (typeof value === 'string') {
         if (value.trim().length > 1) {
            return EmployeeDB.searchByName(value);
        } else if (value.trim().length === 1) {
            return EmployeeDB.searchByMiddleInitial(value);
        } else {
            return { error: 'Invalid search value supplied' };
        }
    } else if (typeof value === 'object' && value !== null) {
        if (Object.keys(value).length === 1) {
            return EmployeeDB.searchByFieldValuePair(value);
        } else if (Object.keys(value).length > 1) {
            return { error: 'Search by multiple fields not supported' };
        } else {
            return { error: 'Invalid search value supplied' };
        }
    } else if (typeof value === 'number') {
        if (!isNaN(value) && isFinite(value) && value > 0 && value % 1 === 0) {
            return EmployeeDB.searchByEmployeeNumber(value);
        } 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:

function searchEmployees(value) {
    switch (xtype.which(value, 'str2+ str1 int+ obj1 obj2+ num nil')) {
        case 'str2+':
            return EmployeeDB.searchByName(value);
        case 'str1':
            return EmployeeDB.searchByMiddleInitial(value);
        case 'int+':
            return EmployeeDB.searchByEmployeeNumber(value);
        case 'obj1':
            return EmployeeDB.searchByFieldValuePair(value);
        case 'obj2+':
            return { error: 'Search by multiple fields not supported' };
        case 'num':
            return { error: 'Invalid employee number supplied' };
        case 'nil':
            return { error: 'No search value supplied' };
        default:
            return { error: 'Invalid search value supplied' };
    }
}

And even add custom validation types of your own:

xtype.ext.registerType('ssn', {
    validator: function(val) {
        return typeof val === 'string' && /^\d{3}-\d{2}-\d{4}$/.test(val);
    }
});

function searchEmployees(value) {
    switch (xtype.which(value, 'positive_integer, ssn, multi_char_string')) {
        case 'positive_integer':
            return EmployeeDB.searchByEmployeeNumber(value);
        case 'ssn':
            return EmployeeDB.searchBySSN(value);
        case 'multi_char_string':
            return EmployeeDB.searchByName(value);
        default:
            return { error: 'Invalid search value supplied' };
    }
}

 

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.

xtype.js.org

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].