Skip to content

Commit

Permalink
feat(invalidTransition): Better error messaging when param values are…
Browse files Browse the repository at this point in the history
… invalid
  • Loading branch information
christopherthielen committed Jun 6, 2017
1 parent 1f2f74a commit 2a15d1a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/transition/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,13 @@ export class Transition implements IHookRegistry {

if (state.self.abstract)
return `Cannot transition to abstract state '${state.name}'`;
if (!Param.validates(state.parameters(), this.params()))
return `Param values not valid for state '${state.name}'`;

const paramDefs = state.parameters(), values = this.params();
const invalidParams = paramDefs.filter(param => !param.validates(values[param.id]));
if (invalidParams.length) {
return `Param values not valid for state '${state.name}'. Invalid params: [ ${invalidParams.map(param => param.id).join(', ')} ]`;
}

if (this.success === false)
return this._error;
}
Expand Down

0 comments on commit 2a15d1a

Please sign in to comment.