src/js/SelectionControls/SelectionControlGroup.js
function requiredByAllControls(validator) {
  return function validate(props, propName, component, ...others) {
    let err = validator(props, propName, component, ...others);

    if (!err && typeof props[propName] === 'undefined') {
      const invalids = props.controls.filter(c => !c[propName]).map((_, i) => i);
      if (invalids.length) {
        const invalidPrefix = invalids.length === props.controls.length
          ? 'All `controls`'
          : `The \`controls\` at indexes \`${invalids.join('`, `')}\``;
        const invalidMsg = `${invalidPrefix} are missing the \`${propName}\` prop.`;

        err = new Error(
          `The \`${propName}\` prop is required to make \`${component}\` accessible for users of ` +
          `assistive technologies such as screen readers. Either add the \`${propName}\` to the \`${component}\` ` +
          `or add the \`${propName}\` to each \`control\` in the \`controls\` prop. ${invalidMsg}`
        );
      }
    }

    return err;
  };
}
function requiredByAllControls(validator) {
  return function validate(props, propName, component, ...others) {
    let err = validator(props, propName, component, ...others);

    if (!err && typeof props[propName] === 'undefined') {
      const invalids = props.controls.filter(c => !c[propName]).map((_, i) => i);
      if (invalids.length) {
        const invalidPrefix = invalids.length === props.controls.length
          ? 'All `controls`'
          : `The \`controls\` at indexes \`${invalids.join('`, `')}\``;
        const invalidMsg = `${invalidPrefix} are missing the \`${propName}\` prop.`;

        err = new Error(
          `The \`${propName}\` prop is required to make \`${component}\` accessible for users of ` +
          `assistive technologies such as screen readers. Either add the \`${propName}\` to the \`${component}\` ` +
          `or add the \`${propName}\` to each \`control\` in the \`controls\` prop. ${invalidMsg}`
        );
      }
    }

    return err;
  };
}
function requiredByAllControls ( validator ) { return function validate ( props , propName , component , ... others ) { let err = validator ( props , propName , component , ... others ) ; if ( ! err && typeof props [ propName ] === 'undefined' ) { const invalids = props . controls . filter ( c => ! c [ propName ] ) . map ( ( _ , i ) => i ) ; if ( invalids . length ) { const invalidPrefix = invalids . length === props . controls . length ? 'All `controls`' : ` \` \` \` ${ invalids . join ( '`, `' ) } \` ` ; const invalidMsg = ` ${ invalidPrefix } \` ${ propName } \` ` ; err = new Error ( ` \` ${ propName } \` \` ${ component } \` ` + ` \` ${ propName } \` \` ${ component } \` ` + ` \` ${ propName } \` \` \` \` \` ${ invalidMsg } ` ) ; } } return err ; } ; }
A custom PropTypes validator to make sure that each `control` in the `controls` prop
contains the given `propName`, or the `SelectionControlGroup` has defined that prop.
A custom PropTypes validator to make sure that each control in the controls prop contains the given propName or the SelectionControlGroup has defined that prop .