Skip to content

Commit 2e84164

Browse files
authored
Merge pull request #449 from storyofams/beta
v1.8.2
2 parents a5d1e09 + a688fbe commit 2e84164

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

lib/internals/validateObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function validateObject(
1919
return value;
2020
}
2121

22-
if (value == null || (typeof value === 'string' && !value.trim().length)) {
22+
if (value == null || typeof value !== 'object') {
2323
value = {};
2424
}
2525

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
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"express-rate-limit": "^6.0.4",
7171
"husky": "8.0.1",
7272
"jest": "26.6.3",
73-
"lint-staged": "13.0.1",
73+
"lint-staged": "13.0.2",
7474
"multer": "^1.4.2",
7575
"next": "12.1.6",
7676
"path-to-regexp": "^6.2.0",

yarn.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5266,10 +5266,10 @@ lines-and-columns@^1.1.6:
52665266
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
52675267
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
52685268

5269-
5270-
version "13.0.1"
5271-
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-13.0.1.tgz#899e78065ab29b88fdd922482411121664ef66be"
5272-
integrity sha512-Ykaf4QTi0a02BF7cnq7JIPGOJxH4TkNMWhSlJdH9wOekd0X+gog47Jfh/0L31DqZe5AiydLGC7LkPqpaNm+Kvg==
5269+
5270+
version "13.0.2"
5271+
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-13.0.2.tgz#35a1c57130e9ad5b1dea784972a40777ba433dd5"
5272+
integrity sha512-qQLfLTh9z34eMzfEHENC+QBskZfxjomrf+snF3xJ4BzilORbD989NLqQ00ughsF/A+PT41e87+WsMFabf9++pQ==
52735273
dependencies:
52745274
cli-truncate "^3.1.0"
52755275
colorette "^2.0.17"
@@ -6861,9 +6861,9 @@ react-is@^17.0.1:
68616861
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
68626862

68636863
react@^18.0.0:
6864-
version "18.1.0"
6865-
resolved "https://registry.yarnpkg.com/react/-/react-18.1.0.tgz#6f8620382decb17fdc5cc223a115e2adbf104890"
6866-
integrity sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ==
6864+
version "18.2.0"
6865+
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
6866+
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==
68676867
dependencies:
68686868
loose-envify "^1.1.0"
68696869

0 commit comments

Comments
 (0)