1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | exports.__esModule = true;
|
13 | exports['default'] = createSinglePropFromChecker;
|
14 |
|
15 | function createSinglePropFromChecker() {
|
16 | for (var _len = arguments.length, arrOfProps = Array(_len), _key = 0; _key < _len; _key++) {
|
17 | arrOfProps[_key] = arguments[_key];
|
18 | }
|
19 |
|
20 | function validate(props, propName, componentName) {
|
21 | var usedPropCount = arrOfProps.map(function (listedProp) {
|
22 | return props[listedProp];
|
23 | }).reduce(function (acc, curr) {
|
24 | return acc + (curr !== undefined ? 1 : 0);
|
25 | }, 0);
|
26 |
|
27 | if (usedPropCount > 1) {
|
28 | var first = arrOfProps[0];
|
29 | var others = arrOfProps.slice(1);
|
30 |
|
31 | var message = others.join(', ') + ' and ' + first;
|
32 | return new Error('Invalid prop \'' + propName + '\', only one of the following ' + ('may be provided: ' + message));
|
33 | }
|
34 | }
|
35 | return validate;
|
36 | }
|
37 |
|
38 | module.exports = exports['default']; |
\ | No newline at end of file |