All Projects → jeffhandley → strickland

jeffhandley / strickland

Licence: MIT License
Strickland is a JavaScript validation framework with a focus on extensibility and composition

Programming Languages

javascript
184084 projects - #8 most used programming language
Vue
7211 projects

Projects that are alternatives of or similar to strickland

svelte-form
JSON Schema form for Svelte v3
Stars: ✭ 47 (+193.75%)
Mutual labels:  validation
openapi-schemas
JSON Schemas for every version of the OpenAPI Specification
Stars: ✭ 22 (+37.5%)
Mutual labels:  validation
apple-receipt
Apple InAppPurchase Receipt - Models, Parser, Validator
Stars: ✭ 25 (+56.25%)
Mutual labels:  validation
Swiftz-Validation
A data structure for validations. It implements the applicative functor interface
Stars: ✭ 15 (-6.25%)
Mutual labels:  validation
kwerri-oss
Kwerri OSS: samvloeberghs.be + jsonld + seo service + scully-plugin-minify-html + scully-plugin-disable-angular
Stars: ✭ 60 (+275%)
Mutual labels:  universal
validator
💯Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
Stars: ✭ 9,721 (+60656.25%)
Mutual labels:  validation
music-app-electron
Music-Streaming app built with Electron, Webpack, Vue.js, Vuex and the Spotify api.
Stars: ✭ 74 (+362.5%)
Mutual labels:  universal
validada
Another library for defensive data analysis.
Stars: ✭ 29 (+81.25%)
Mutual labels:  validation
xrechnung-schematron
Schematron rules for the German CIUS (XRechnung) of EN16931:2017
Stars: ✭ 19 (+18.75%)
Mutual labels:  validation
flask-pydantic
flask extension for integration with the awesome pydantic package
Stars: ✭ 181 (+1031.25%)
Mutual labels:  validation
validation
Validation on Laravel 5.X|6.X|7.X|8.X
Stars: ✭ 26 (+62.5%)
Mutual labels:  validation
laravel-pwned-passwords
Simple Laravel validation rule that allows you to prevent or limit the re-use of passwords that are known to be pwned (unsafe). Based on TroyHunt's Have I Been Pwned (https://haveibeenpwned.com)
Stars: ✭ 67 (+318.75%)
Mutual labels:  validation
ttv
A command line tool for splitting files into test, train, and validation sets.
Stars: ✭ 38 (+137.5%)
Mutual labels:  validation
oolong
oolong 🍵 : create and administrate validation tests for typical automated content analysis tools.
Stars: ✭ 40 (+150%)
Mutual labels:  validation
nexus-validate
🔑 Add argument validation to your GraphQL Nexus API.
Stars: ✭ 29 (+81.25%)
Mutual labels:  validation
onixcheck
ONIX validation library and commandline tool
Stars: ✭ 20 (+25%)
Mutual labels:  validation
webargs-starlette
Declarative request parsing and validation for Starlette with webargs
Stars: ✭ 36 (+125%)
Mutual labels:  validation
is-valid-domain
Validate domain name in JavaScript
Stars: ✭ 50 (+212.5%)
Mutual labels:  validation
ruby-magic
Simple interface to libmagic for Ruby Programming Language
Stars: ✭ 23 (+43.75%)
Mutual labels:  validation
fefe
Validate, sanitize and transform values with proper TypeScript types and zero dependencies.
Stars: ✭ 34 (+112.5%)
Mutual labels:  validation

Readme

Strickland is a JavaScript validation framework with a focus on extensibility and composability. It is built with pure, universal JavaScript and while it works well with React, Redux, and other UI libraries, Strickland is not coupled to any other library or application type.

Strickland is a unique and robust approach to building validation into your application.

  • It is not a type system and it does not interfere with how you create and manage objects
  • Instead, validation rules are defined separately from the data
  • While Strickland can be used within the UI layer (including React components or Redux modules), it is not limited to use within UI
  • Universal applications can share validators across both client-side and server-side validation
  • With its extensibility and composability, Strickland supports complex scenarios in large line-of-business applications

Strickland focuses not on being a bloated collection of validators, but instead on enabling you to create your application's collection of validators and compose them together easily.

Separation of Concerns

In any validation implementation, there are three separate concerns that you must address, regardless of the libraries used.

  1. Validation Rules are the logic of how data is validated
  2. Validation Triggers are the events that trigger validation to occur at the field or form level
  3. Validation Results are presented to the user as the output of your validation rules

The most robust, flexible, and maintainable validation implementations keep these three concerns separated. Validation rules should not be coupled to the validation triggers or how the results will be presented. Validation triggers should not be coupled in any way to the validation rules or how the results will be presented. And the presentation of validation results should not be coupled to how validation was triggered or what the rules were.

With this separation of concerns in mind, Strickland strives to:

  1. Provide a flexible framework for authoring validation rules so that many different types of validation rules can be authored while remaining decoupled from validation triggers and how validation results are displayed
  2. Be completely uninvolved in validation triggers so that consuming applications can be built with any UI frameworks and without imposing any opinions on user interactions
  3. Provide a consistent structure for exposing validation results so that they can be consumed by applications consistently regardless of how many or what types of validation rules are present

Core Concepts

To address the core concepts above, there are three core concepts you need to know with Strickland:

  1. Validators are implementations of your validation rules
  2. Validation is the act of executing a validator against a value
  3. Validation Results are the output of validation for the given validator and value

Creating Validators

Strickland validators are pure functions that accept values and return validation results. Here is an extremely simple validator that validates that the value supplied is the letter 'A', returning the validation result as a boolean.

function letterA(value) {
    return (value === 'A');
}

Performing Validation

Strickland's default export is a validate function that accepts a validator function and the value to validate against the validator; it returns the validation result.

import validate from 'strickland';

function letterA(value) {
    return (value === 'A');
}

const result = validate(letterA, 'B');

Validation Results

Strickland normalizes validation results to always be objects with isValid and value properties.

If the validator returns a falsy value, then isValid will be false. If the validator returns true, then isValid will be true. If the validator returns an object, the truthiness of its isValid property will be used on the result's isValid property.

The value on the validation result will always be the value that was validated.

import validate from 'strickland';

function letterA(value) {
    // We can return a validation result as a boolean
    return (value === 'A');

    // Or as an object
    // return {
    //    isValid: (value === 'A')
    // };
}

const result = validate(letterA, 'B');

// Either way, the result will match:
//
// result = {
//     isValid: false,
//     value: 'B'
// }

License

MIT

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].