JSPM

  • Created
  • Published
  • Downloads 1957580
  • Score
    100M100P100Q70071F
  • License MIT

Custom React PropType validators that we use at Airbnb.

Package Exports

  • airbnb-prop-types
  • airbnb-prop-types/src/mutuallyExclusiveProps
  • airbnb-prop-types/src/nonNegativeInteger

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 (airbnb-prop-types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

prop-types Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

Custom React PropType validators that we use at Airbnb.

  • childrenHavePropXorChildren: ensure that either all children have the indicated prop, all children have children, or all children have neither.
  • childrenOfType: restrict the prop to only allow children of the given type.
  • componentWithName: restrict the prop to only allow a component with a certain name/displayName.
  • mutuallyExclusiveProps: provide a propType, and a list of props, and only one prop out of the list will be permitted, validated by the given propType.
  • nChildren: require a specific amount of children.
  • nonNegativeInteger: require that the prop be a number, that is 0, or a positive integer.
  • or: recursively allows only the provided propTypes, or arrays of those propTypes.
  • range: provide a min, and a max, and the prop must be a number in the range [min, max)
  • restrictedProp: this prop is not permitted to be anything but null or undefined.

Tests

Simply clone the repo, npm install, and run npm test