src/utils/index.js
// Custom validation function for a single slider in the 'sliders' prop
Custom validation function for a single slider in the 'sliders' prop
Custom validation function for a single slider in the ' sliders ' prop
function validateSlider(sliders, axis, componentName, location, propFullName) {
  const slider = sliders[axis];
  if (slider.length !== 2) {
    return new Error(
      `Invalid prop '${propFullName}' supplied to '${componentName}'. ` +
        `${propFullName} must be an array of length 2.`
    );
  }
  if (slider[0] > slider[1]) {
    return new Error(
      `Invalid prop '${propFullName}' supplied to '${componentName}'. ` +
        `${propFullName}[0] must be <= ${propFullName}[1].`
    );
  }
  for (const [idx, val] of slider.entries()) {
    if (val < 0 || val > 1) {
      return new Error(
        `Invalid prop '${propFullName}' supplied to '${componentName}'. ` +
          `slider[${idx}] must be between 0 and 1 (inclusive)`
      );
    }
  }
}
function validateSlider ( sliders , axis , componentName , location , propFullName ) { const slider = sliders [ axis ] ; if ( slider . length !== 2 ) { return new Error ( ` ${ propFullName } ${ componentName } ` + ` ${ propFullName } ` ) ; } if ( slider [ 0 ] > slider [ 1 ] ) { return new Error ( ` ${ propFullName } ${ componentName } ` + ` ${ propFullName } ${ propFullName } ` ) ; } for ( const [ idx , val ] of slider . entries ( ) ) { if ( val < 0 || val > 1 ) { return new Error ( ` ${ propFullName } ${ componentName } ` + ` ${ idx } ` ) ; } } }
Custom validation function for a single slider in the 'sliders' prop
Custom validation function for a single slider in the ' sliders ' prop
// Array length is exactly 2 // Minimum slider value must be <= maximum // Slider values must be between 0 and 1