I'm working on an ASP.NET MVC application where I have a set of view models used for different forms. The client is mainly copying data from an Excel sheet into these forms.
I.e. a view model for person:
public class Person
{
[Required]
[Display(Name = "First name")]
public string FirstName { get; set;}
}
When client is pasting a value from Excel into this field, the actual value stored in the database (using Entity Framework 6 fyi) contains an invisible line break.
Is there any way to make a custom data annotation which, essentially, parses the input string and returns the parsed value? Or do I have to make a method for parsing the input and use it everywhere in my code where I save data?
Thanks in advance.