Skip to content
/ vtypes Public

✔️ Additional validation rules / contraints for validate.js to address other common data patterns

License

Notifications You must be signed in to change notification settings

yeojz/vtypes

Repository files navigation

vtypes-package

Additional validation rules / contraints for validate.js to address other common data patterns

npm package Build Status Coverage Status vtypes

Overview

vtypes is built on top of validate.js, providing additional validation rules for certain data patterns / data types.

Build Formats

vtypes is available in a variety of builds & module formats.

All packages by default exposes a module in commonjs format. However, a umd bundle is also available within each package if you prefer that. i.e. Instead of require('vtypes-*') use require('vtypes-*/umd').

Validators

For more information, do check their individual README.md in their respective folders.

Note: Those listed as yes in the column Default will be included in vtypes and vtypes-register packages.

Base

Validator Default Description
arrayOf yes allows recursive validation of an array content
array yes checks for array (empty array is also valid)
bool yes must be of type boolean
different yes must have a different value than the provided field.
func yes must be a type function
invariant yes conditional check based on a truthy result of a function
json yes must be a valid JSON string.
objectOf yes object with property values following a certain validation rule
only yes must be the ONLY ONE present amongst specified attributes
shape yes allows recursive validation of nested object
string yes must be a type string

Immutable

Validator Default Description
immutable yes checks for immutable resource
size yes same as the built in "length" validator, but uses "size" instead.

Laravel

The following validators are inspired from the built-in validation rules of Laravel

Validator Default Description
requiredIf yes required if the another attribute is present or equal to any value.
requiredUnless yes required unless the another attribute is equal to any value.
requiredWith yes required if ANY of the other specified attributes are present.
requiredWithAll yes required if ALL of the other specified attributes are present.
requiredWithout yes required when ANY of the specified attributes are not present
requiredWithoutAll yes required when ALL of the specified attributes are not present

License

vtypes is MIT licensed

About

✔️ Additional validation rules / contraints for validate.js to address other common data patterns

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published