0.1.3 • Published 4 years ago

@reliutg/vprops v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

vprops

Object property async validation

Installation

npm i @reliutg/vprops

Usage

import { vprops } from '@reliutg/vprops'

const myObject = {
    title: 'aaaa',
    getName: '',
    isMale: true
}

const myValidations = {
    title: 'string',
    getName: 'function',
    isMale: 'boolean',
}

(async () => {
    // Validate a single property
    const a = await vprops(myObject, myValidations, 'isMale')
    console.log(a.isValid) // true

    // Also can validate multiple properties
    console.log(b.areValid) // false

    // Validate all object properties
    const b = await vprops(myObject, myValidations)
    console.log(b.areValid) // false

    // Check if some properties are valid
    console.log(b.someValid) // true
})()
0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago