From bac79cd74a6de679533eed12ae71f6a6c6a4e802 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Wed, 15 Jan 2025 11:04:18 +0100 Subject: [PATCH] fix: update error.constraints conditions --- api/src/utils/pipes/object-id.pipe.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/utils/pipes/object-id.pipe.ts b/api/src/utils/pipes/object-id.pipe.ts index fd2d1527..4685e6ff 100644 --- a/api/src/utils/pipes/object-id.pipe.ts +++ b/api/src/utils/pipes/object-id.pipe.ts @@ -33,7 +33,7 @@ export class ObjectIdPipe implements PipeTransform> { async transform(value: string, { type, data }: ArgumentMetadata) { if (typeof value === 'string' && data === 'id' && type === 'param') { const errors = await this.getErrors(value); - if (errors.constraints) + if (errors?.constraints) throw new BadRequestException(Object.values(errors.constraints)[0]); } else if ( typeof value === 'object' && @@ -45,7 +45,7 @@ export class ObjectIdPipe implements PipeTransform> { if (param.startsWith('id')) { const errors = await this.getErrors(String(paramValue)); - if (errors.constraints) + if (errors?.constraints) throw new BadRequestException( Object.values(errors.constraints)[0], );