Skip to content

Commander-lol/node-validate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!')
}

About

A simple & powerful object schema validation library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published