@Transform() applies a custom transformation function when class-transformer converts an object. Use it when a type conversion is too complex for @Type() alone — such as splitting a comma-separated string into an array, parsing a date string into a Date instance, or sanitizing a value by trimming and lowercasing.
@Type(() => Date) — use for straightforward class instantiation of nested objects.
@Transform() — use when the conversion requires custom logic, parsing, or conditions.
@Transform() also runs during serialization (instanceToPlain) — useful for formatting dates as ISO strings in responses.
The transform function receives { value, key, obj, type } — the full context of the conversion.
transform: true must be enabled in ValidationPipe for @Transform() to execute on incoming data.