Socket
Socket
Sign inDemoInstall

formalist-validation

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    formalist-validation

Data validation library for Formalist based on predicate logic.


Version published
Weekly downloads
97
decreased by-20.49%
Maintainers
1
Install size
33.6 kB
Created
Weekly downloads
 

Changelog

Source

v1.0.0 2017-02-23

  • Releasing as v1.0.0 for better semver compatibility.

Readme

Source

Formalist Validation

Data validation library for Formalist based on predicate logic.

The scope of the library is very simple. It tests a value against a given schema and returns an array of relevant error messages.

Usage

import validation from 'formalist-validation'

// Define a schema
const schema = {
  "filled": true,
  "min_size": 2,
  "max_size": 3,
}

// Curry validator with the schema
const validator = validation(schema)

// Test
validator([1])
// => ['size cannot be less than 2']
validator([1,2])
// => []
validator([1,2,3])
// => []
validator([1,2,3,4])
// => ['size cannot be greater than 3']

View the full list of available predicates to see what else you can test.

Caveats

  • Tests will only be run if there’s a value to test or the schema specifies that to test that the value is 'filled'.
  • All the predicate tests are run as logical ANDs. There’s no support for more complex logic at at the moment.

TODO

  • Allow custom validations to be injected
  • i18n support

FAQs

Last updated on 23 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc