Skip to content

feature: add nullable option for IsNotEmptyObject decorator #678

Closed
@NoNameProvided

Description

@NoNameProvided

Description

This issue us copied and modified from PR #635 by @ytetsuro,

Currently, the @IsNotEmptyObject decorator allows objects with null values only. I would like an option for the @IsNotEmptyObject decorator to fail validation when all object property is null or undefined.

Proposed solution

Minimal example of proposed feature:

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: done/releasedIssue has been completed, no further action is needed.type: featureIssues related to new features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions