feat: Add class-validator decorators to update DTOs with PartialType inheritance and CI enforcement#1081
Merged
Merged
Conversation
…inheritance and CI enforcement Applied class-validator decorators (@IsString, @isarray, @IsOptional, @isboolean, @IsEnum, @isnumber, @isnotempty, @ValidateNested, @type) to seven update/request DTOs that previously accepted arbitrary payloads, enabling the global ValidationPipe (configured with whitelist: true and forbidNonWhitelisted: true) to reject unknown and mistyped properties with 400 responses. - sync-action.dto.ts — Added missing class-validator imports so existing @IsString()/@isObject() decorators work at runtime. - sync-batch.dto.ts — Added @isarray(), @ValidateNested({ each: true }), @type(() => SyncActionDto), and required imports for proper nested validation. - gdpr-export.dto.ts — Added @IsOptional() and type decorators on all excluded fields to establish a non-empty whitelist while preserving @exclude() serialization behavior. - achievement.dto.ts — Decorated CreateAchievementDto with full validation and converted UpdateAchievementDto to extends PartialType(CreateAchievementDto) with additional optional fields, keeping validation in sync automatically. - Created scripts/validate-dto-decorators.js — a CI check that asserts every *.dto.ts file has class-validator decorators, uses PartialType, or is a class-level @exclude() response DTO. Added as lint:dto script and included in the verify pipeline. - Added 5 spec files (23 total tests) verifying valid payloads pass, invalid types are rejected, and PartialType inheritance works correctly. Closes rinafcode#1040
|
@onajidavid87-web Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Well done on the job done so far! |
Contributor
|
thank you for contributing to the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Applied class-validator decorators (@IsString, @isarray, @IsOptional, @isboolean, @IsEnum, @isnumber, @isnotempty, @ValidateNested, @type) to seven update/request DTOs that previously accepted arbitrary payloads, enabling the global ValidationPipe (configured with whitelist: true and forbidNonWhitelisted: true) to reject unknown and mistyped properties with 400 responses.
Closes #1040