Skip to content

Commit

Permalink
fix(jsii-spec): show deep validation errors (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr authored and RomainMuller committed Apr 15, 2019
1 parent 675b86a commit 4d84e0b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/jsii-spec/lib/validate-assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export const schema: jsonschema.Schema = require('../schema/jsii-spec.schema.jso

export function validateAssembly(obj: any): Assembly {
const validator = new jsonschema.Validator();
const result = validator.validate(obj, schema);
validator.addSchema(schema); // For definitions
const result = validator.validate(obj, schema, { nestedErrors: true } as any); // nestedErrors does exist but is not in the TypeScript definitions
if (result.valid) { return obj; }
throw new Error(`Invalid assembly:\n${result}`);
}
}

0 comments on commit 4d84e0b

Please sign in to comment.