@commander-lol/validate

Simple & powerful schema validation library

Stats

StarsIssuesVersionUpdatedCreatedSize
@commander-lol/validate
001.0.15 years ago5 years agoMinified + gzip package size for @commander-lol/validate in KB

Readme

Validate

install

yarn add @commander-lol/validate

usage


import Validate from '@commander-lol/validate'

const validator = Validate({
    name: name => !name && 'Required',
    mobile: [
        mobile => !mobile && 'Required',
        mobile => !isNaN(Number(mobile)) ? null : 'Must be a valid number',
    ],
})

const errors = validator({ name: 'Hugo', mobile: '0555123444' })

if (errors) {
    for (let error in errors) {
        console.log(error, errors[error])
    }
} else {
    console.log('No errors!')
}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.