Skip to content

Commit be91543

Browse files
committed
test: validation of stringified bodies
1 parent 9d6f8a9 commit be91543

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/pipes/validators/validation.pipe.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,19 @@ describe('ValidationPipe', () => {
6565

6666
expect(ValidationPipe()('', { metaType: DTO })).rejects.toThrowError(BadRequestException);
6767
});
68+
69+
it('Should throw for a stringified JSON body.', () => {
70+
class DTO {
71+
@IsNotEmpty()
72+
@IsEmail()
73+
public email!: string;
74+
75+
@IsNotEmpty()
76+
public name!: string;
77+
}
78+
79+
expect(
80+
ValidationPipe()('{"email":"[email protected]","name":"Hello world"}', { metaType: DTO })
81+
).rejects.toThrowError(BadRequestException);
82+
});
6883
});

0 commit comments

Comments
 (0)