src/components/Toggle.js
function validateChoices(props, propName, componentName) {
  const propValue = props[propName];
  if (!propValue) {
    return undefined;
  }

  if (!Array.isArray(propValue) || propValue.length !== 2) {
    return new Error(`Invalid ${propName} supplied to \`${componentName}\`, expected exactly two Choice components.`);
  }

  for (let i = 0; i < propValue.length; ++i) {
    const item = propValue[i];
    if (!item || !isComponentOfType(Choice, item)) {
      return new Error(`Invalid ${propName}[${i}] supplied to \`${componentName}\`, expected a Choice component from Belle.`);
    }
  }

  if (first(propValue).props.value === last(propValue).props.value) {
    return new Error(`Invalid ${propName} supplied to \`${componentName}\`, expected different value properties for the provided Choice components.`);
  }

  return undefined;
}
function validateChoices(props, propName, componentName) {
  const propValue = props[propName];
  if (!propValue) {
    return undefined;
  }

  if (!Array.isArray(propValue) || propValue.length !== 2) {
    return new Error(`Invalid ${propName} supplied to \`${componentName}\`, expected exactly two Choice components.`);
  }

  for (let i = 0; i < propValue.length; ++i) {
    const item = propValue[i];
    if (!item || !isComponentOfType(Choice, item)) {
      return new Error(`Invalid ${propName}[${i}] supplied to \`${componentName}\`, expected a Choice component from Belle.`);
    }
  }

  if (first(propValue).props.value === last(propValue).props.value) {
    return new Error(`Invalid ${propName} supplied to \`${componentName}\`, expected different value properties for the provided Choice components.`);
  }

  return undefined;
}
function validateChoices ( props , propName , componentName ) { const propValue = props [ propName ] ; if ( ! propValue ) { return undefined ; } if ( ! Array . isArray ( propValue ) || propValue . length !== 2 ) { return new Error ( ` ${ propName } \` ${ componentName } \` ` ) ; } for ( let i = 0 ; i < propValue . length ; ++ i ) { const item = propValue [ i ] ; if ( ! item || ! isComponentOfType ( Choice , item ) ) { return new Error ( ` ${ propName } ${ i } \` ${ componentName } \` ` ) ; } } if ( first ( propValue ) . props . value === last ( propValue ) . props . value ) { return new Error ( ` ${ propName } \` ${ componentName } \` ` ) ; } return undefined ; }
Verifies that the children is an array containing only two choices with a
different value.
Verifies that the children is an array containing only two choices with a different value .