(props, propName, componentName, location, propFullName, secret)
| 401 | |
| 402 | function createPrimitiveTypeChecker(expectedType) { |
| 403 | function validate(props, propName, componentName, location, propFullName, secret) { |
| 404 | var propValue = props[propName]; |
| 405 | var propType = getPropType(propValue); |
| 406 | if (propType !== expectedType) { |
| 407 | // `propValue` being instance of, say, date/regexp, pass the 'object' |
| 408 | // check, but we can offer a more precise error message here rather than |
| 409 | // 'of type `object`'. |
| 410 | var preciseType = getPreciseType(propValue); |
| 411 | |
| 412 | return new PropTypeError( |
| 413 | 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'), |
| 414 | {expectedType: expectedType} |
| 415 | ); |
| 416 | } |
| 417 | return null; |
| 418 | } |
| 419 | return createChainableTypeChecker(validate); |
| 420 | } |
| 421 |
no test coverage detected
searching dependent graphs…