(props, propName, componentName, location, propFullName, secret)
| 3976 | |
| 3977 | function createPrimitiveTypeChecker(expectedType) { |
| 3978 | function validate(props, propName, componentName, location, propFullName, secret) { |
| 3979 | var propValue = props[propName]; |
| 3980 | var propType = getPropType(propValue); |
| 3981 | if (propType !== expectedType) { |
| 3982 | // `propValue` being instance of, say, date/regexp, pass the 'object' |
| 3983 | // check, but we can offer a more precise error message here rather than |
| 3984 | // 'of type `object`'. |
| 3985 | var preciseType = getPreciseType(propValue); |
| 3986 | |
| 3987 | return new PropTypeError( |
| 3988 | 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'), |
| 3989 | {expectedType: expectedType} |
| 3990 | ); |
| 3991 | } |
| 3992 | return null; |
| 3993 | } |
| 3994 | return createChainableTypeChecker(validate); |
| 3995 | } |
| 3996 |
no test coverage detected