Skip to content

Why is @Expose() decorator required to create new property fields? #1508

Open
@Krrish-raj

Description

@Krrish-raj

Say I have the following class definition:

export class Filter {
    @IsEnum(FilterType)
    id: FilterType

    @IsString()
    /* This is not getting executed. **/
    @Transform(({ obj }) => LabelGenerator.getfilterTypeLabel(obj.id), { toClassOnly: true })
    label: string;

    @IsEnum(FilterSelectType)
    select: FilterSelectType;
}

I am using a plain object: {id: 'Sample', select: 'multi'} to create the class.

In the above case, @Transform decorator is not getting executed, but if I put @expose() decorator on top of that, it works as expected. Is this the expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionQuestions about the usage of the library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions