Skip to content

feature: extends discriminator lookup #857

Open
@getlarge

Description

@getlarge

Description

I truly appreciate the possibility to have pseudo dynamic class in my models.
Unfortunately, it's not always possible to add a new specific property to make the lookup working and moreover quite often the discriminator can already be found in the parent object.

export class SignTransaction {
  @Type(() => Identity)
  @ValidateNested()
  identity: Identity;

  @Type(() => LedgerTransaction, {
    discriminator: {
      property: ['identity', 'coinType'],
      parentProperty: true,
      subTypes: [
        { value: BigChainTransaction, name: 822 },
        { value: EthereumTransaction, name: 60 },
      ],
    },
    keepDiscriminatorProperty: true,
  })
  @ValidateNested()
  transaction: BigChainTransaction | EthereumTransaction;
}

Proposed solution

  • Allow to lookup discriminator in parent value
  • Allow search through nested properties
  • Allow subTypes.name to be string or number

Relates to :

Metadata

Metadata

Assignees

No one assigned

    Labels

    flag: needs discussionIssues which needs discussion before implementation.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