Skip to content

fix: isNotEmptyObject nullable option works opposite way #1554

Open

Description

@arkist

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()

Activity

  1. added
    status: needs triage
    type: fix
    on Feb 17, 2022
  2. added
    status: fixed
    and removed
    status: needs triage
    on Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: fixedtype: fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions