I want to implement a validators for my class.
I have two class and one of these is called as array of object in one of my class attribute:
enter image description here
When I try to send the json through postman, the validators tells me that:
must be a number conforming to the specified constraints
This is my ValidationPipe in the main.ts:
app.useGlobalPipes(
new ValidationPipe({
disableErrorMessages: false,
enableDebugMessages: true,
}));
And this is my method in controller:
@UseGuards(AuthGuard)
@Post()
async create(@Body() createDiscussion: CreateDiscussionDto): Promise<Discussion> {
return await this.discussionService.createDiscussion(createDiscussion);
}
How is this possibile if I'm sending the value as number? Thanks
I expect that the error message will disappear and works when I really send a not number value.
CodePudding user response:
The problem doesn't come from your codebase. It actually comes from your request body.
When you take a deeper look at the JSON from your Postman request, there is a :
character inside the property name "like:":
while it should just be "like":
.