209 похожих чатов

Час копаясь я чудом нашел баг с кастомным ValidationPipe. Есть такой

валидейшен пайп и он используется глобально.
@Injectable()
export class ValidationPipe implements PipeTransform<any> {
async transform(value: any, metadata: ArgumentMetadata): Promise<any> {
if (!value) {
throw new BadRequestException('No data submitted');
}

const obj = plainToClass(metadata.metatype, value);

const errors = await validate(obj);

if (errors.length) {
const validationErrorData = errors
.map((error) => {
for (const key in error.constraints) {
return error.constraints[key];
}
})
.join(', ');

throw new ValidationException({
message: validationErrorData,
error: 'Bad Request',
});
}

return value;
}
}

Проблема возникает когда я делаю "гет" запрос с параметром в строке динамическим @Get('confirmRegistration/:value').
Ошибка возникает в валидейшен пайп тут const errors = await validate(obj); когда передаю obj в validate. Там будет значение из строки урла /:value и при этом упадет с ошибкой TypeError: Cannot read property 'constructor' of undefined, ну ис текттрейс который меня туда привел(в валидейшен пайп). Почему возникает такая проблема?

1 ответов

17 просмотров

Подскажите, получилось ли у Вас найти решение проблемы?) Или условие в начале и есть решение?

Похожие вопросы

Обсуждают сегодня

Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
Also, why can’t the community have a vote/ say when it comes to initiatives like buybacks. Isn’t the point of crypto decentralisation? Don’t we deserve input as long term supp...
👨🏽‍🦰
13
any reference of this implementation?
BitBuddha
29
Hi guys, any problem with Pulsebrige? Trying to transfer from wETH to ETH. First it tells me to connect my metamask "through mobile app" not desktop. Then I did and confirmed ...
Snowflakecrypto
13
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Ⓐrtto, [4/23/24 7:02 PM] Please explain more fully how it is not working exactly, and what are the steps you are taking, and what error messages come or what happens. Ⓐrtto, ...
Ezza Kezza
2
Btw looks like Kushti is at it with 6.0, has he shared any plans to stop developing Ergo or just to keep going indefinitely?
Original Ergonaut Manley
16
sounds like people have lost their kaspa on tradeogre... does this mean tradeogre not trustworthy?
Ezza Kezza
15
So much speculation in the last week. So much volatility in price. This is because Hedera has a GC that isn't using the network it's governing. Why aren't people asking why a...
Summit Seeker R
9
Question: How viable is it to use Anvil as the backend infrastructure for managing a TradFi portfolio, while integrating Flexa for instant liquidity and payment solutions? Cou...
Kevin
2
Карта сайта