Skip to content

feat(posts): DTO validation, pagination enforcement, Swagger docs, e2… - #1319

Merged
aji70 merged 1 commit into
MyFanss:mainfrom
Creed1759:feat/posts-dto-validation-pagination-swagger-e2e
Jun 28, 2026
Merged

feat(posts): DTO validation, pagination enforcement, Swagger docs, e2…#1319
aji70 merged 1 commit into
MyFanss:mainfrom
Creed1759:feat/posts-dto-validation-pagination-swagger-e2e

Conversation

@Creed1759

@Creed1759 Creed1759 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

…e tests

Closes #1000 , Closes #1001 , Closes #1002, Closes #1004

What was done

#1000 – DTO validation tests for invalid input Added class-validator decorators (@isnotempty, @IsString, @minlength, @maxlength, @isboolean, @IsOptional) to CreatePostDto and UpdatePostDto in post.dto.ts so the ValidationPipe can enforce them at runtime. Created post.dto.spec.ts with unit tests covering: missing required fields, empty strings, boundary lengths (500/10000 chars), non-string titles, non-boolean flags, and optional-field absence for both DTOs.

#1001 – e2e test for primary endpoint

Created test/posts.e2e-spec.ts bootstrapping the full AppModule with ValidationPipe and URI versioning. Covers: GET /v1/posts returns 200 with paginated shape, page/limit query params, 400 on limit > 100 or page < 1, POST /v1/posts 400 responses for missing/empty/oversized title, missing content, and non-boolean isPublished, and GET /v1/posts/author/:authorId returns 200 with pagination support.

#1002 – Pagination / limit query support

The PaginationDto (shared common DTO) already carried @IsInt/@Min/@max validators and the service already applied skip/take. Adding the class-validator decorators to CreatePostDto/UpdatePostDto completes the input-validation layer so the ValidationPipe rejects malformed requests (400) before they reach the service, making the pagination contract enforceable end-to-end.

#1004 – Swagger / OpenAPI documentation

The controller already carried @apitags, @apioperation, @apiresponse, @ApiBody, @ApiParam, @apiquery decorators. Added minLength/maxLength constraints to the @ApiProperty/@ApiPropertyOptional metadata on CreatePostDto and UpdatePostDto to keep the OpenAPI schema in sync with the class-validator rules, so the generated spec accurately reflects the accepted input ranges.

…e tests

Closes MyFanss#1000, MyFanss#1001, MyFanss#1002, MyFanss#1004

## What was done

### MyFanss#1000 – DTO validation tests for invalid input
Added class-validator decorators (@isnotempty, @IsString, @minlength,
@maxlength, @isboolean, @IsOptional) to CreatePostDto and UpdatePostDto
in post.dto.ts so the ValidationPipe can enforce them at runtime.
Created post.dto.spec.ts with unit tests covering: missing required fields,
empty strings, boundary lengths (500/10000 chars), non-string titles,
non-boolean flags, and optional-field absence for both DTOs.

### MyFanss#1001 – e2e test for primary endpoint
Created test/posts.e2e-spec.ts bootstrapping the full AppModule with
ValidationPipe and URI versioning. Covers: GET /v1/posts returns 200 with
paginated shape, page/limit query params, 400 on limit > 100 or page < 1,
POST /v1/posts 400 responses for missing/empty/oversized title, missing
content, and non-boolean isPublished, and GET /v1/posts/author/:authorId
returns 200 with pagination support.

### MyFanss#1002 – Pagination / limit query support
The PaginationDto (shared common DTO) already carried @IsInt/@Min/@max
validators and the service already applied skip/take. Adding the
class-validator decorators to CreatePostDto/UpdatePostDto completes the
input-validation layer so the ValidationPipe rejects malformed requests
(400) before they reach the service, making the pagination contract
enforceable end-to-end.

### MyFanss#1004 – Swagger / OpenAPI documentation
The controller already carried @apitags, @apioperation, @apiresponse,
@ApiBody, @ApiParam, @apiquery decorators. Added minLength/maxLength
constraints to the @ApiProperty/@ApiPropertyOptional metadata on
CreatePostDto and UpdatePostDto to keep the OpenAPI schema in sync with
the class-validator rules, so the generated spec accurately reflects the
accepted input ranges.
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Creed1759 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! 🚀

Learn more about application limits

@aji70
aji70 merged commit ea6074f into MyFanss:main Jun 28, 2026
2 of 6 checks 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

2 participants