MCPcopy Create free account
hub / github.com/plotly/dash / createChainableTypeChecker

Function createChainableTypeChecker

dash/deps/prop-types@15.8.1.js:344–400  ·  view source on GitHub ↗
(validate)

Source from the content-addressed store, hash-verified

342 PropTypeError.prototype = Error.prototype;
343
344 function createChainableTypeChecker(validate) {
345 if ("development" !== 'production') {
346 var manualPropTypeCallCache = {};
347 var manualPropTypeWarningCount = 0;
348 }
349 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
350 componentName = componentName || ANONYMOUS;
351 propFullName = propFullName || propName;
352
353 if (secret !== ReactPropTypesSecret) {
354 if (throwOnDirectAccess) {
355 // New behavior only for users of `prop-types` package
356 var err = new Error(
357 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
358 'Use `PropTypes.checkPropTypes()` to call them. ' +
359 'Read more at http://fb.me/use-check-prop-types'
360 );
361 err.name = 'Invariant Violation';
362 throw err;
363 } else if ("development" !== 'production' && typeof console !== 'undefined') {
364 // Old behavior for people using React.PropTypes
365 var cacheKey = componentName + ':' + propName;
366 if (
367 !manualPropTypeCallCache[cacheKey] &&
368 // Avoid spamming the console because they are often not actionable except for lib authors
369 manualPropTypeWarningCount < 3
370 ) {
371 printWarning(
372 'You are manually calling a React.PropTypes validation ' +
373 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
374 'and will throw in the standalone `prop-types` package. ' +
375 'You may be seeing this warning due to a third-party PropTypes ' +
376 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
377 );
378 manualPropTypeCallCache[cacheKey] = true;
379 manualPropTypeWarningCount++;
380 }
381 }
382 }
383 if (props[propName] == null) {
384 if (isRequired) {
385 if (props[propName] === null) {
386 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
387 }
388 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
389 }
390 return null;
391 } else {
392 return validate(props, propName, componentName, location, propFullName);
393 }
394 }
395
396 var chainedCheckType = checkType.bind(null, false);
397 chainedCheckType.isRequired = checkType.bind(null, true);
398
399 return chainedCheckType;
400 }
401

Callers 12

createAnyTypeCheckerFunction · 0.85
createArrayOfTypeCheckerFunction · 0.85
createElementTypeCheckerFunction · 0.85
createEnumTypeCheckerFunction · 0.85
createUnionTypeCheckerFunction · 0.85
createNodeCheckerFunction · 0.85
createShapeTypeCheckerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…