From a98f5dd3e5693f112837f81befc600c66ba49885 Mon Sep 17 00:00:00 2001 From: Xavier Martin Date: Tue, 15 Oct 2019 22:12:34 +1300 Subject: [PATCH] fix: create instance of ValidationError for whitelist errors (#434) Fix #325 --- src/validation/ValidationExecutor.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/validation/ValidationExecutor.ts b/src/validation/ValidationExecutor.ts index bfa27f9f18..36e63d0f2f 100644 --- a/src/validation/ValidationExecutor.ts +++ b/src/validation/ValidationExecutor.ts @@ -111,10 +111,10 @@ export class ValidationExecutor { // throw errors notAllowedProperties.forEach(property => { - validationErrors.push({ - target: object, property, value: (object as any)[property], children: undefined, - constraints: { [ValidationTypes.WHITELIST]: `property ${property} should not exist` } - }); + const validationError: ValidationError = this.generateValidationError(object, (object as any)[property], property); + validationError.constraints = { [ValidationTypes.WHITELIST]: `property ${property} should not exist` }; + validationError.children = undefined; + validationErrors.push(validationError); }); } else {