init
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Kreta.Web.ModelBinder.Mvc
|
||||
{
|
||||
public class StringTrimModelBinder : IModelBinder
|
||||
{
|
||||
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
|
||||
{
|
||||
var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
|
||||
var attemptedValue = value?.AttemptedValue;
|
||||
|
||||
return string.IsNullOrWhiteSpace(attemptedValue) ? null : attemptedValue.Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user