Open
Description
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 :
- feat: allow
subTypes.name
to be a number inDiscriminatorDescriptor
#737 - fix: DiscriminatorDescriptor interface now accepts number, too #582
- feature: increase flexibility of discriminator by allowing a function in addition to the property #552
- feature: support path property (or function) in discriminator option #510