(props, propName, componentName, location, propFullName, secret)
| 1149 | |
| 1150 | function createPrimitiveTypeChecker(expectedType) { |
| 1151 | function validate(props, propName, componentName, location, propFullName, secret) { |
| 1152 | var propValue = props[propName]; |
| 1153 | var propType = getPropType(propValue); |
| 1154 | if (propType !== expectedType) { |
| 1155 | // `propValue` being instance of, say, date/regexp, pass the 'object' |
| 1156 | // check, but we can offer a more precise error message here rather than |
| 1157 | // 'of type `object`'. |
| 1158 | var preciseType = getPreciseType(propValue); |
| 1159 | |
| 1160 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); |
| 1161 | } |
| 1162 | return null; |
| 1163 | } |
| 1164 | return createChainableTypeChecker(validate); |
| 1165 | } |
| 1166 |
no test coverage detected