1 | const formatToList = items => items.map(key => `- ${key}`).join('\n');
|
2 |
|
3 | export default function validatePathConfig(config) {
|
4 | let root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
5 | const validKeys = ['initialRouteName', 'screens'];
|
6 |
|
7 | if (!root) {
|
8 | validKeys.push('path', 'exact', 'stringify', 'parse');
|
9 | }
|
10 |
|
11 | const invalidKeys = Object.keys(config).filter(key => !validKeys.includes(key));
|
12 |
|
13 | if (invalidKeys.length) {
|
14 | 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.`);
|
15 | }
|
16 |
|
17 | if (config.screens) {
|
18 | Object.entries(config.screens).forEach(_ref => {
|
19 | let [_, value] = _ref;
|
20 |
|
21 | if (typeof value !== 'string') {
|
22 | validatePathConfig(value, false);
|
23 | }
|
24 | });
|
25 | }
|
26 | }
|
27 |
|
\ | No newline at end of file |