diff --git a/src/construct.ts b/src/construct.ts index 1dc25ce8..109f7a38 100644 --- a/src/construct.ts +++ b/src/construct.ts @@ -400,19 +400,7 @@ export class Node { * construct. */ public validate(): string[] { - const deprecated = ['validate', 'onValidate', 'synthesize', 'onSynthesize', 'prepare', 'onPrepare']; - for (const method of deprecated) { - if (typeof((this.host as any)[method]) === 'function') { - throw new Error(`the construct "${this.path}" has a "${method}()" method which is no longer supported. Use "construct.node.addValidation()" to add validations to a construct`); - } - } - - const errors = new Array(); - for (const v of this._validations) { - errors.push(...v.validate()); - } - - return errors; + return this._validations.flatMap(v => v.validate()); } /** diff --git a/test/construct.test.ts b/test/construct.test.ts index ecfee0da..ebc92941 100644 --- a/test/construct.test.ts +++ b/test/construct.test.ts @@ -641,21 +641,6 @@ test('Construct.isConstruct returns true for constructs', () => { expect(Construct.isConstruct(someRandomObject)).toBeFalsy(); }); -describe('hard deprecations', () => { - const methods = ['validate', 'onValidate', 'synthesize', 'onSynthesize', 'prepare', 'onPrepare']; - - for (const method of methods) { - test(method, () => { - const c = new Construct(new Root(), 'MyConstruct'); - Object.defineProperty(c, method, { - value: () => [], - }); - - expect(() => c.node.validate()).toThrow(/no longer supported/); - }); - } -}); - function createTree(context?: any) { const root = new Root(); const highChild = new Construct(root, 'HighChild');