Package Exports
- ow-prop-type
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ow-prop-type) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ow-prop-type
React prop-types validation with ow
- when
process.env.NODE_ENV
is'production'
it will be a shim function - it exports the
ow
object (or shim in'production'
) as a property - will return the unprocessed
ArgumentError
Why
prop-types has only very basic validation, and it is super verbose to add custom validators.
Example
import propType, { ow } from 'ow-prop-type'
class MyComponent extends React.Component {
static propTypes = {
// propType with a predicate
total: propType(
ow
.number
.integer
.greaterThanOrEqual(0)
),
// propType with a callback, must return a predicate
current: propType((props) => {
return ow
.number
.integer
.greaterThanOrEqual(0)
.lessThanOrEqual(props.total)
}
}
}