(props, propName, componentName, location, propFullName, secret)
| 1270 | |
| 1271 | function createPrimitiveTypeChecker(expectedType) { |
| 1272 | function validate(props, propName, componentName, location, propFullName, secret) { |
| 1273 | var propValue = props[propName]; |
| 1274 | var propType = getPropType(propValue); |
| 1275 | if (propType !== expectedType) { |
| 1276 | // `propValue` being instance of, say, date/regexp, pass the 'object' |
| 1277 | // check, but we can offer a more precise error message here rather than |
| 1278 | // 'of type `object`'. |
| 1279 | var preciseType = getPreciseType(propValue); |
| 1280 | |
| 1281 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); |
| 1282 | } |
| 1283 | return null; |
| 1284 | } |
| 1285 | return createChainableTypeChecker(validate); |
| 1286 | } |
| 1287 |
no test coverage detected