Custom typeFn
for date strings?
#384
-
A common use case we have for automapper is converting We'd love to be able to define a DTO like this: export class FooDto {
@AutoMap({ typeFn: () => DateString })
date?: DateString;
} This could use a custom export class DateString extends String {
constructor(value: unknown) {
super(formatAsDateString(value));
}
} (This specific implementation is admittedly gross — I'm just riffing on the Is there way to implement something similar with automapper? Ideally we'd like to use the same pattern to convert any type of non-JSON-serializable object to strings. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 18 replies
-
what about custom type converters? |
Beta Was this translation helpful? Give feedback.
-
The issue with that approach is that sometimes we want to map a Is there a way to implement a custom type converter that can distinguish between these two cases? |
Beta Was this translation helpful? Give feedback.
-
can you show how you're using |
Beta Was this translation helpful? Give feedback.
can you show how you're using
ConvertUsing
?