1 | 'use strict';
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.errMsg = errMsg;
|
5 | exports.createChainableTypeChecker = createChainableTypeChecker;
|
6 |
|
7 | function errMsg(props, propName, componentName, msgContinuation) {
|
8 | return 'Invalid prop \'' + propName + '\' of value \'' + props[propName] + '\'' + (' supplied to \'' + componentName + '\'' + msgContinuation);
|
9 | }
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | function createChainableTypeChecker(validate) {
|
19 | function checkType(isRequired, props, propName, componentName) {
|
20 | componentName = componentName || '<<anonymous>>';
|
21 | if (props[propName] == null) {
|
22 | if (isRequired) {
|
23 | return new Error('Required prop \'' + propName + '\' was not specified in \'' + componentName + '\'.');
|
24 | }
|
25 | } else {
|
26 | return validate(props, propName, componentName);
|
27 | }
|
28 | }
|
29 |
|
30 | var chainedCheckType = checkType.bind(null, false);
|
31 | chainedCheckType.isRequired = checkType.bind(null, true);
|
32 |
|
33 | return chainedCheckType;
|
34 | } |
\ | No newline at end of file |