Checker Factory
Checker Factory used by Deku Prop Type Validators
Install
npm install --save checker-factory
Usage
const numberChecker = numberChecker// => TypeError: Expected age to be of type `number`, but got `string` numberChecker// => undefined const requiredString = isRequired requiredString// => Error: name is required const evenNumberChecker = evenNumberChecker// => Error: Expected id to be an even number const checkerWithName = checkerWithNamename// => 'dog'
API
checkerFactory(validator[, name])
Returns a CheckerFactory with an isRequired
getter and validate
function.
validator
type: function
| string
If validator
is a string
, then a typeof
check will be performed. If validator
is a function
, then the function will be execution. The function is passed the prop
value and the key
name.
name
type: string
This is an optional value to retrieve a name for the checker factory.
License
MIT © Dustin Specker