We are in the process of using NodaTime for time / date models in our project. The project is a web application, using WebAPI. When attempting to post a model containing Loc
It appears to be a WebAPI issue, but I don't fully understand the root cause, nor do I particularly like this solution. However, based on the code in this answer, I came up with a workaround:
public class CustomBodyModelValidator : DefaultBodyModelValidator
{
public override bool ShouldValidateType(Type type)
{
return type.Namespace != "NodaTime" && base.ShouldValidateType(type);
}
}
In your configuration lambda (or wherever you are accessing the global WebAPI configuration:
x.Services.Replace(typeof(IBodyModelValidator), new CustomBodyModelValidator());
Consider this a hack of a workaround until I (or someone else) can figure out a better solution. Thanks.
Update: On further research, it appears this has already been posted to the Noda Time issue tracker as issue #249, and a similar solution was proposed.