I'm using Mvc6 beta6 and model is passed in Json format. What is the recommended way to trim all values inside json model before it is validated? I also need to trim values of strings of nested objects inside the model.
Here is an example:
[HttpPut("{userId}/{id}/details")]
public async Task<IActionResult> UpdateProfileDetails(string userId, string id, [FromBody] UserProfileDetailsModel userProfileDetailsModel)
{
// Inside the action all (nested)values of userProfileDetailsModel should be already trimmed without the need to trim them manually based on model type
}
So provided userProfileDetailsModel has a nested object "geoLocation" : { "continent" : " EU "} the effect I'm trying to obtain is having the continent value trimmed as "EU" when reading this value inside the action.
I'm looking for a global filter or global formatter solution which does not depend on model type.