Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: isNotEmptyObject nullable option works opposite way #1554

Open
arkist opened this issue Feb 17, 2022 · 0 comments · Fixed by #1555
Open

fix: isNotEmptyObject nullable option works opposite way #1554

arkist opened this issue Feb 17, 2022 · 0 comments · Fixed by #1555
Labels
status: fixed Issues with merged PRs, but not released yet. type: fix Issues describing a broken feature.

Comments

@arkist
Copy link
Contributor

arkist commented Feb 17, 2022

Description

nullable option for @IsNotEmptyObject but it works the opposite way.

Expected behavior

expected behavior from previous example in #678 is:

class MyClass {
  @IsNotEmptyObject()
  notStrictModeInvalid = { }; // invalid

  @IsNotEmptyObject()
  notStrictModeValid = { key1: null, key2: undefined }; // valid

  @IsNotEmptyObject({ nullable: false })
  strcitModeInvalid = { }; // invalid

  @IsNotEmptyObject({ nullable: false })
  strcitModeValid = { key1: null, key2: undefined }; // invalid

  @IsNotEmptyObject({ nullable: false })
  strcitModeValid = { key1: 'key', key2: undefined }; // valid
}

Actual behavior

in the current test suite, there's no test for nullable: false case.
for nullable: true testing, null and undefined are being treated as invalid values.

here are some tests to prove:

// FAIL
expect(
  isNotEmptyObject({ key1: null, key2: undefined }, { nullable: false })
).toBeFalsy()

// FAIL
expect(
  isNotEmptyObject({ key1: null, key2: undefined }, { nullable: true })
).toBeTruthy()
@arkist arkist added status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature. labels Feb 17, 2022
@NoNameProvided NoNameProvided added status: fixed Issues with merged PRs, but not released yet. and removed status: needs triage Issues which needs to be reproduced to be verified report. labels Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: fixed Issues with merged PRs, but not released yet. type: fix Issues describing a broken feature.
Development

Successfully merging a pull request may close this issue.

2 participants