1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = validatePathConfig;
|
7 |
|
8 | const formatToList = items => items.map(key => `- ${key}`).join('\n');
|
9 |
|
10 | function validatePathConfig(config) {
|
11 | let root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
12 | const validKeys = ['initialRouteName', 'screens'];
|
13 |
|
14 | if (!root) {
|
15 | validKeys.push('path', 'exact', 'stringify', 'parse');
|
16 | }
|
17 |
|
18 | const invalidKeys = Object.keys(config).filter(key => !validKeys.includes(key));
|
19 |
|
20 | if (invalidKeys.length) {
|
21 | throw new Error(`Found invalid properties in the configuration:\n${formatToList(invalidKeys)}\n\nDid you forget to specify them under a 'screens' property?\n\nYou can only specify the following properties:\n${formatToList(validKeys)}\n\nSee https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.`);
|
22 | }
|
23 |
|
24 | if (config.screens) {
|
25 | Object.entries(config.screens).forEach(_ref => {
|
26 | let [_, value] = _ref;
|
27 |
|
28 | if (typeof value !== 'string') {
|
29 | validatePathConfig(value, false);
|
30 | }
|
31 | });
|
32 | }
|
33 | }
|
34 |
|
\ | No newline at end of file |