src/utils/index.js
// Custom validation function for a single model in the 'models' prop
Custom validation function for a single model in the 'models' prop
Custom validation function for a single model in the ' models ' prop
function validateModel(models, idx, componentName, location, propFullName) {
  const model = models[idx];
  const modelNames = new Set();
  for (const model of models) {
    if (modelNames.has(model.name))
      return new Error(
        `Invalid prop '${propFullName}' supplied to '${componentName}'. ` +
          `Name '${model.name}' is not unique in 'models'.`
      );
    else modelNames.add(model.name);
  }
  try {
    if ("colorMaps" in model) validateColorMaps(model.colorMaps, model.name);
    if ("transferFunction" in model)
      validateTransferFunction(model.transferFunction);
  } catch (error) {
    return new Error(
      `Invalid prop '${propFullName}' supplied to '${componentName}'. ` +
        error.message
    );
  }
}
function validateModel ( models , idx , componentName , location , propFullName ) { const model = models [ idx ] ; const modelNames = new Set ( ) ; for ( const model of models ) { if ( modelNames . has ( model . name ) ) return new Error ( ` ${ propFullName } ${ componentName } ` + ` ${ model . name } ` ) ; else modelNames . add ( model . name ) ; } try { if ( "colorMaps" in model ) validateColorMaps ( model . colorMaps , model . name ) ; if ( "transferFunction" in model ) validateTransferFunction ( model . transferFunction ) ; } catch ( error ) { return new Error ( ` ${ propFullName } ${ componentName } ` + error . message ) ; } }
Custom validation function for a single model in the 'models' prop
Custom validation function for a single model in the ' models ' prop
// Each model must have a unique name