Prop Typ Utils is a collection of useful* prop type validation rules.
npm install prop-type-utils[![npm package][npm-badge]][npm]
Prop Typ Utils is a collection of _useful_ prop type validation rules.

Logo designed by Liffy Designs
Install
```
npm i prop-type-utils
Use
You can import the named utils from the main package:
`javascript
import { includes, isGreaterThan } from 'prop-type-utils';
......
static propTypes = {
age: isGreaterThan(18),
title: includes('cool')
}
`
Or you can import the individual utils as you need them
`javascript
import isBetween from 'prop-type-utils/lib/isBetween';
......
static propTypes = {
score: isBetween(10, 60)
}
`
`javascript
import isEven from 'prop-type-utils/isEven';
Foo.propTypes = {
bar: isEven
}
//Examples
//Error
//Success
`
`javascript
import isGreaterThan from 'prop-type-utils/isGreaterThan';
Foo.propTypes = {
bar: isGreaterThan(5)
}
//Examples
//Error
//Success
`
`javascript
import isLessThan from 'prop-type-utils/isLessThan';
Foo.propTypes = {
bar: isLessThan(5)
}
//Examples
//Error
//Success
`
`javascript
import isBetween from 'prop-type-utils/isBetween';
Foo.propTypes = {
bar: isBetween(5, 10)
}
//Examples
//Error
//Success
`
`javascript
import includes from 'prop-type-utils/includes';
Foo.propTypes = {
bar: includes('react')
}
//Examples
//Error
//Success
`
`javascript
import includes from 'prop-type-utils/isRequiredWhen';
Foo.propTypes = {
isShowing: PropTypes.bool
bar: isRequiredWhen('isShowing')
}
//Examples
//Error
//Success
`
`javascript
import isRequiredWhenAll from 'prop-type-utils/isRequiredWhenAll';
Foo.propTypes = {
isShowing: PropTypes.bool,
foo: PropTypes.string,
bar: isRequiredWhenAll(['isShowing', 'foo'])
}
//Examples
//Error
//Error
//Success
//Success
`
`javascript
import isOnlyOneAllowed from 'prop-type-utils/isOnlyOneAllowed';
Foo.propTypes = {
isShowing: isOnlyOneAllowed(['isShowing','foo', 'bar']),
foo: isOnlyOneAllowed(['isShowing','foo', 'bar']),
bar: isOnlyOneAllowed(['isShowing','foo', 'bar'])
}
//Examples
//Error
//Error
//Success
//Success
``
[build-badge]: https://img.shields.io/travis/user/repo/master.png?style=flat-square
[build]: https://travis-ci.org/user/repo
[npm-badge]: https://img.shields.io/npm/v/npm-package.png?style=flat-square
[npm]: https://www.npmjs.org/package/npm-package