Trim string Fields #826
-
|
is there any way to tell mapperly to auto trim input strings? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Mapperly will use methods provided to it see here [Mapper]
Public static class MyMapper
{
// your mappers go here
// mapperly will use this for all string -> string mapping
Public static string Trimmer(string input) => input.Trim();
} |
Beta Was this translation helpful? Give feedback.
-
|
I haven't started using Mapperly yet and I'm in the research stage. I was wondering, can this be configured on a global/default level? Maybe something with MapperDefaults? Basically, every time I map from string to string, anywhere, if the source is null or whitespace, I want to return null, otherwise I want to return the trimmed string. (I know, I know, feels hacky, but it is what it is) In automapper, I do a ValueTransfers.Add(...) once when setting up my mapper configuration and I never deal with it again. |
Beta Was this translation helpful? Give feedback.
Mapperly will use methods provided to it see here