Skip to content

Commit

Permalink
Merge pull request #449 from storyofams/beta
Browse files Browse the repository at this point in the history
v1.8.2
  • Loading branch information
ggurkal committed Jun 24, 2022
2 parents a5d1e09 + a688fbe commit 2e84164
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/internals/validateObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function validateObject(
return value;
}

if (value == null || (typeof value === 'string' && !value.trim().length)) {
if (value == null || typeof value !== 'object') {
value = {};
}

Expand Down
15 changes: 15 additions & 0 deletions lib/pipes/validators/validation.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,19 @@ describe('ValidationPipe', () => {

expect(ValidationPipe()('', { metaType: DTO })).rejects.toThrowError(BadRequestException);
});

it('Should throw for a stringified JSON body.', () => {
class DTO {
@IsNotEmpty()
@IsEmail()
public email!: string;

@IsNotEmpty()
public name!: string;
}

expect(
ValidationPipe()('{"email":"hello@storyofams.com","name":"Hello world"}', { metaType: DTO })
).rejects.toThrowError(BadRequestException);
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"express-rate-limit": "^6.0.4",
"husky": "8.0.1",
"jest": "26.6.3",
"lint-staged": "13.0.1",
"lint-staged": "13.0.2",
"multer": "^1.4.2",
"next": "12.1.6",
"path-to-regexp": "^6.2.0",
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5266,10 +5266,10 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

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

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

Expand Down

1 comment on commit 2e84164

@vercel
Copy link

@vercel vercel bot commented on 2e84164 Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.