Skip to content

Latest commit

 

History

History
25 lines (21 loc) · 573 Bytes

README.md

File metadata and controls

25 lines (21 loc) · 573 Bytes

Validator

A light-weight validator, that applies a rule-set against a value, and returns the failures.

The rules are processed in the order of the example:

import validate from '@shady/validator'

// returns [] if there are no failing rules
const errors = validate(value, {
    required: boolean,
    min: number,
    max: number,
    gte: number,
    lte: number,
    pattern: RegExp | string,
    match: any,
    differ: any,
    differs: any[],
    email: boolean,
    onOrAfter: Date | string | number,
    onOrBefore: Date | string | number,
})