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], );