-
-
Notifications
You must be signed in to change notification settings - Fork 193
Closed as not planned
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Feature Request
A new function named classTransform that converts a given input into an instance of a specific class.
The function could have the following signature:
typia.classTransform<T>(input: Primitive<T>): T;
This function takes two arguments:
- input: The primitive input to be converted.
- T: The target class that the input should be transformed into.
The function should return an instance of the class T with the given input.
This function would be particularly useful for converting raw input data into class instances. This issue is critical as it prevents proper type validation and transformation of the incoming request body, a common requirement in type-safe server-side applications. (see samchon/nestia#431)
Example Usage
Here is an example of how this function could be used:
class Foo {
constructor(public value: string) {}
bar() {
return this.value;
}
}
const input = {value: "test"};
const transformed = typia.classTransform<Test>(input);
console.log(transformed.bar()); // Should log: "test"
DavidVaness, Namchee, Val0429, DCNick3, a-kla and 3 moreCopilot
Metadata
Metadata
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed