fix(router): throw if config does not contain required fields

This commit is contained in:
Brian Ford 2015-05-01 15:50:12 -07:00
parent 68ed8f1b6b
commit 259f872cea
1 changed files with 9 additions and 0 deletions

View File

@ -14,6 +14,15 @@ export class RouteRegistry {
config(parentComponent, config) { config(parentComponent, config) {
if (!StringMapWrapper.contains(config, 'path')) {
throw new BaseException('Route config does not contain "path"');
}
if (!StringMapWrapper.contains(config, 'component') &&
!StringMapWrapper.contains(config, 'components')) {
throw new BaseException('Route config does not contain "component" or "components"');
}
var recognizer:RouteRecognizer; var recognizer:RouteRecognizer;
if (MapWrapper.contains(this._rules, parentComponent)) { if (MapWrapper.contains(this._rules, parentComponent)) {
recognizer = MapWrapper.get(this._rules, parentComponent); recognizer = MapWrapper.get(this._rules, parentComponent);