CADELmx / GPD_BACKEND

This is a NESTjs project that implements the GPD project's backend logic
MIT License
1 stars 0 forks source link

Add custom ParseIntPipe for messages on error #34

Closed DiegoSHS closed 1 month ago

DiegoSHS commented 2 months ago

Custom instances Add custom instances of ParseIntPipe for every controller, this ensures that the validation of datatypes is sending the right messages. Example:

    @Put(':id')
    update(@Param('id', new ParseIntPipe({
        exceptionFactory: () => {
            return new BadRequestException('El id no es un número');
        }
    })) id: number, @Body() updateDto: UpdateDto) {
        return this.exampleService.update(id, updateDto);
    }
DiegoSHS commented 2 months ago

Validación de Query params y Params