MCPcopy
hub / github.com/angular/angular / validateNode

Function validateNode

packages/router/src/utils/config.ts:88–211  ·  view source on GitHub ↗
(route: Route, fullPath: string, requireStandaloneComponents: boolean)

Source from the content-addressed store, hash-verified

86}
87
88function validateNode(route: Route, fullPath: string, requireStandaloneComponents: boolean): void {
89 if (typeof ngDevMode === 'undefined' || ngDevMode) {
90 if (!route) {
91 throw new RuntimeError(
92 RuntimeErrorCode.INVALID_ROUTE_CONFIG,
93 `
94 Invalid configuration of route '${fullPath}': Encountered undefined route.
95 The reason might be an extra comma.
96
97 Example:
98 const routes: Routes = [
99 { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
100 { path: 'dashboard', component: DashboardComponent },, << two commas
101 { path: 'detail/:id', component: HeroDetailComponent }
102 ];
103 `,
104 );
105 }
106 if (Array.isArray(route)) {
107 throw new RuntimeError(
108 RuntimeErrorCode.INVALID_ROUTE_CONFIG,
109 `Invalid configuration of route '${fullPath}': Array cannot be specified`,
110 );
111 }
112 if (
113 !route.redirectTo &&
114 !route.component &&
115 !route.loadComponent &&
116 !route.children &&
117 !route.loadChildren &&
118 route.outlet &&
119 route.outlet !== PRIMARY_OUTLET
120 ) {
121 throw new RuntimeError(
122 RuntimeErrorCode.INVALID_ROUTE_CONFIG,
123 `Invalid configuration of route '${fullPath}': a componentless route without children or loadChildren cannot have a named outlet set`,
124 );
125 }
126 if (route.redirectTo && route.children) {
127 throw new RuntimeError(
128 RuntimeErrorCode.INVALID_ROUTE_CONFIG,
129 `Invalid configuration of route '${fullPath}': redirectTo and children cannot be used together`,
130 );
131 }
132 if (route.redirectTo && route.loadChildren) {
133 throw new RuntimeError(
134 RuntimeErrorCode.INVALID_ROUTE_CONFIG,
135 `Invalid configuration of route '${fullPath}': redirectTo and loadChildren cannot be used together`,
136 );
137 }
138 if (route.children && route.loadChildren) {
139 throw new RuntimeError(
140 RuntimeErrorCode.INVALID_ROUTE_CONFIG,
141 `Invalid configuration of route '${fullPath}': children and loadChildren cannot be used together`,
142 );
143 }
144 if (route.component && route.loadComponent) {
145 throw new RuntimeError(

Callers 1

validateConfigFunction · 0.85

Calls 4

assertStandaloneFunction · 0.85
validateConfigFunction · 0.85
isArrayMethod · 0.80
charAtMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…