In the Nancy code you have this in DefaultBinder on line 181
private bool BindingValueIsValid(string bindingValue, object existingValue, BindingMemberInfo modelProperty, BindingContext bindingContext)
{
return (!String.IsNullOrEmpty(bindingValue) &&
(IsDefaultValue(existingValue, modelProperty.PropertyType) ||
bindingContext.Configuration.Overwrite));
}
When sending across empty strings as values sure enough my properties are being set (or rather not being set at all) to null. To me this should not be the default behavior as I do want to have a distinction between empty strings and nulls. There's also no option to change this at least that I can tell.
Any work arounds? Why does this seem to be the default behavior in Nancy, and ASP.NET MVC and others?
Seems to be a bug. I've submitted a pull request: