Skip to content

Conversation

@SORVER
Copy link
Contributor

@SORVER SORVER commented Oct 23, 2025

This pull request introduces input validation for incoming requests using NestJS's ValidationPipe, and adds the required dependencies for class-based validation and transformation. These changes help ensure that only expected and properly formatted data is accepted by the application.

Input validation and transformation:

  • Configured a global ValidationPipe in src/main.ts to automatically validate and transform incoming request payloads according to DTO classes, enforce whitelisting, and forbid non-whitelisted properties.

  • When whitelist is true, NestJS will automatically remove any properties from the incoming data that are not defined in your DTO class.

  • When forbidNonWhitelisted is true, instead of removing the extra properties, NestJS will throw an error if it finds any field not defined in your DTO.

  • When transform is true, NestJS will automatically transform payloads to be objects typed according to their DTO classes.

Dependency additions:

  • Added class-transformer and class-validator packages to package.json to support DTO-based validation and transformation.

@OsamaRab3 OsamaRab3 requested a review from gazzaar October 23, 2025 19:08
src/main.ts Outdated
Comment on lines 7 to 16

/*
Warning for the AC team:
When whitelist is true, NestJS will automatically remove any properties from the incoming data that are not defined in your DTO class.
When forbidNonWhitelisted is true, instead of removing the extra properties, NestJS will throw an error if it finds any field not defined in your DTO.
When transform is true, NestJS will automatically transform payloads to be objects typed according to their DTO classes.
# hint for the future: while making users module add a dto folder inside users module and define your dtos there.
# TODO: add common dtos for requests and responses
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pleas remove all comment here

Copy link
Member

@gazzaar gazzaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Please remove the comments, as the details have already been explained in the pr description.

@OsamaRab3 OsamaRab3 merged commit 5e5e8aa into Async-AC-Team:main Oct 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants