mirror of
https://github.com/hexastack/hexabot
synced 2025-03-10 06:10:18 +00:00
fix: update error.constraints conditions
This commit is contained in:
parent
2a25f19448
commit
bac79cd74a
@ -33,7 +33,7 @@ export class ObjectIdPipe implements PipeTransform<string, Promise<string>> {
|
||||
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<string, Promise<string>> {
|
||||
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],
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user