Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/modules/charges/application/dto/create-charge.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createZodDto } from 'nestjs-zod';
import { z } from 'zod';

const CreateChargeSchema = z.object({
amount: z.number().int().min(1),
amount: z.number().int().min(1).max(2147483647),
currency: z.string().length(3),
payer_document: z.string().regex(/^\d{11}$/, 'payer_document must be an 11-digit CPF'),
description: z.string().optional(),
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/charges.controller.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ describe('ChargesController (e2e)', () => {
expect(res.status).toBe(400);
});

it('retorna 400 quando amount excede o limite inteiro (validação Zod)', async () => {
const res = await request(app.getHttpServer())
.post('/charges')
.set('Idempotency-Key', uuidv4())
.send({ ...validBody, amount: 2147483648 });

expect(res.status).toBe(400);
});

it('retorna 400 quando currency está ausente (validação Zod)', async () => {
const res = await request(app.getHttpServer())
.post('/charges')
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
"exclude": ["node_modules", "test", "dist", "**/*spec.ts", "vitest.config.ts"]
}
Loading