Description
I have a class with a property of type of another class.
@exclude()
export class A {
@ValidateNested({each: true, groups: CEG})
@isdefined({groups: CEG})
@IsNotEmptyObject({nullable: false}, {groups: CEG})
config: ConfigClass;
@ApiProperty()
@Expose({groups: VAG})
device: string;
}
@exclude()
export class ConfigClass {
@ApiProperty()
@expose({ groups: AG })
@Transform(value => value || null, { toClassOnly: true })
@ValidateIf(o => o.settings !== null, { groups: CEG })
@IsRequired({ groups: CEG })
@MaxLength(128, { groups: CEG })
settings: string;
@ApiProperty()
@Expose({ groups: AG })
@Transform(value => value || 10, { toClassOnly: true })
@IsNotEmpty({ groups: CEG })
@IsInt({ groups: CEG })
@Min(1, { groups: CEG })
@Max(600, { groups: CEG })
snooze: number;
}
I want to exclude in plainToClass properties from the nested property also.
plainToClass(A, response.data as A[], {
groups: VEG
, excludeExtraneousValues: true
, enableImplicitConversion: true
, excludePrefixes: ['device']
}));
Here im excluding the device property with is not nested. I want the config class to be transformed also but without the snooze property.
How can i do that?