mirror of
https://github.com/hexastack/hexabot
synced 2025-03-10 14:25:42 +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) {
|
async transform(value: string, { type, data }: ArgumentMetadata) {
|
||||||
if (typeof value === 'string' && data === 'id' && type === 'param') {
|
if (typeof value === 'string' && data === 'id' && type === 'param') {
|
||||||
const errors = await this.getErrors(value);
|
const errors = await this.getErrors(value);
|
||||||
if (errors.constraints)
|
if (errors?.constraints)
|
||||||
throw new BadRequestException(Object.values(errors.constraints)[0]);
|
throw new BadRequestException(Object.values(errors.constraints)[0]);
|
||||||
} else if (
|
} else if (
|
||||||
typeof value === 'object' &&
|
typeof value === 'object' &&
|
||||||
@ -45,7 +45,7 @@ export class ObjectIdPipe implements PipeTransform<string, Promise<string>> {
|
|||||||
if (param.startsWith('id')) {
|
if (param.startsWith('id')) {
|
||||||
const errors = await this.getErrors(String(paramValue));
|
const errors = await this.getErrors(String(paramValue));
|
||||||
|
|
||||||
if (errors.constraints)
|
if (errors?.constraints)
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
Object.values(errors.constraints)[0],
|
Object.values(errors.constraints)[0],
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user