Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add decorator for implicit conversion #532

Closed
JEVietti opened this issue Dec 23, 2020 · 2 comments
Closed

feature: add decorator for implicit conversion #532

JEVietti opened this issue Dec 23, 2020 · 2 comments
Labels
status: wontfix type: feature Issues related to new features.

Comments

@JEVietti
Copy link

Description

It would be nice instead of having to call plainToClass with enableImplicitConversion: true, in certain situations across the codebase, if I could mark the property or even all properties of a certain class to always function as if enableImplicitConversion: true. This is specifically an issue in nested transformations, where I have a deeply nested class that I want implicit conversions to take place for a property with type Moment., as it is already in moment form from the form and will throw an error otherwise.

Proposed solution

Add a decorator such as @EnableImplicitTypeConversion() that can mark a property or class to act as though implicit conversion was enabled in the call of plainToClass. I will say that this should act as a default and any value provided in the actual plainToClass call should probably take precedent or have an extra option to override, but that's more of your decision on how that can/should be handled.

@NoNameProvided NoNameProvided added type: feature Issues related to new features. status: wontfix labels Jan 14, 2021
@NoNameProvided
Copy link
Member

Decorators will be added to cast primitive values during the transformation. (See #550) For non-primitive values, you should use a @Type or @Transform decorator.

Your requested feature @EnableImplicitTypeConversion() won't be implemented as you can easily replicate it with a @Type or Transform decorator.

@NoNameProvided NoNameProvided changed the title feature: Add Decorator for Implicit Conversion feature: add Decorator for Implicit Conversion Jan 14, 2021
@NoNameProvided NoNameProvided changed the title feature: add Decorator for Implicit Conversion feature: add decorator for implicit conversion Jan 14, 2021
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: wontfix type: feature Issues related to new features.
Development

No branches or pull requests

2 participants