How to use the prop-types-extra/lib/utils/createChainableTypeChecker function in prop-types-extra

To help you get started, we’ve selected a few prop-types-extra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jquense / react-widgets / packages / react-widgets / src / util / PropTypes.js View on Github external
import elementType
  from 'prop-types-extra/lib/elementType';
import createChainableTypeChecker
  from 'prop-types-extra/lib/utils/createChainableTypeChecker';

import { date, number } from './localizers';

export { elementType }

export const numberFormat = createChainableTypeChecker(
  (...args) => number.propType(...args))

export const dateFormat = createChainableTypeChecker(
  (...args) => date.propType(...args))

export const disabled = createChainableTypeChecker(
  (...args) => PropTypes.bool(...args));

disabled.acceptsArray = PropTypes.oneOfType([disabled, PropTypes.array])

export const accessor = PropTypes.oneOfType([
  PropTypes.string,
  PropTypes.func,
])

export const message = PropTypes.oneOfType([
  PropTypes.node,
  PropTypes.string,
  PropTypes.func,
])
github jquense / react-widgets / packages / react-widgets / src / util / PropTypes.js View on Github external
import PropTypes from 'prop-types';
import elementType
  from 'prop-types-extra/lib/elementType';
import createChainableTypeChecker
  from 'prop-types-extra/lib/utils/createChainableTypeChecker';

import { date, number } from './localizers';

export { elementType }

export const numberFormat = createChainableTypeChecker(
  (...args) => number.propType(...args))

export const dateFormat = createChainableTypeChecker(
  (...args) => date.propType(...args))

export const disabled = createChainableTypeChecker(
  (...args) => PropTypes.bool(...args));

disabled.acceptsArray = PropTypes.oneOfType([disabled, PropTypes.array])

export const accessor = PropTypes.oneOfType([
  PropTypes.string,
  PropTypes.func,
])

export const message = PropTypes.oneOfType([
  PropTypes.node,
  PropTypes.string,
  PropTypes.func,
github jquense / react-widgets / packages / react-widgets / src / util / PropTypes.js View on Github external
import PropTypes from 'prop-types';
import elementType
  from 'prop-types-extra/lib/elementType';
import createChainableTypeChecker
  from 'prop-types-extra/lib/utils/createChainableTypeChecker';

import { date, number } from './localizers';

export { elementType }

export const numberFormat = createChainableTypeChecker(
  (...args) => number.propType(...args))

export const dateFormat = createChainableTypeChecker(
  (...args) => date.propType(...args))

export const disabled = createChainableTypeChecker(
  (...args) => PropTypes.bool(...args));

disabled.acceptsArray = PropTypes.oneOfType([disabled, PropTypes.array])

export const accessor = PropTypes.oneOfType([
  PropTypes.string,
  PropTypes.func,
])

export const message = PropTypes.oneOfType([
github react-bootstrap / react-bootstrap / src / utils / PropTypes.js View on Github external
export function requiredRoles(...roles) {
  return createChainableTypeChecker((props, propName, component) => {
    let missing;

    roles.every(role => {
      if (
        !ValidComponentChildren.some(
          props.children,
          child => child.props.bsRole === role,
        )
      ) {
        missing = role;
        return false;
      }

      return true;
    });
github react-bootstrap / react-bootstrap / src / utils / PropTypes.js View on Github external
export function exclusiveRoles(...roles) {
  return createChainableTypeChecker((props, propName, component) => {
    let duplicate;

    roles.every(role => {
      const childrenWithRole = ValidComponentChildren.filter(
        props.children,
        child => child.props.bsRole === role,
      );

      if (childrenWithRole.length > 1) {
        duplicate = role;
        return false;
      }

      return true;
    });