MCPcopy Create free account
hub / github.com/reactjs/react-rails / validate

Function validate

lib/assets/react-source/development/react.js:30622–30637  ·  view source on GitHub ↗
(props, propName, componentName, location, propFullName, secret)

Source from the content-addressed store, hash-verified

30620
30621 function createPrimitiveTypeChecker(expectedType) {
30622 function validate(props, propName, componentName, location, propFullName, secret) {
30623 var propValue = props[propName];
30624 var propType = getPropType(propValue);
30625 if (propType !== expectedType) {
30626 // `propValue` being instance of, say, date/regexp, pass the 'object'
30627 // check, but we can offer a more precise error message here rather than
30628 // 'of type `object`'.
30629 var preciseType = getPreciseType(propValue);
30630
30631 return new PropTypeError(
30632 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
30633 {expectedType: expectedType}
30634 );
30635 }
30636 return null;
30637 }
30638 return createChainableTypeChecker(validate);
30639 }
30640

Callers 1

checkTypeFunction · 0.70

Calls 8

hasFunction · 0.85
getPropTypeFunction · 0.70
getPreciseTypeFunction · 0.70
isValidElementFunction · 0.70
getClassNameFunction · 0.70
isFunction · 0.70
isNodeFunction · 0.70
invalidValidatorErrorFunction · 0.70

Tested by

no test coverage detected