CarterCommunity / Carter

Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.
MIT License
2.1k stars 175 forks source link

Binding from Form data can throw if there is a mismatch in fields. #132

Closed JoeStead closed 5 years ago

JoeStead commented 5 years ago

When binding from a FormCollection you can get a null reference exception if the fields do not match up properly.

Given the type Document:

public class Document
{
   public string Type { get; set; }
}

and the form data:

name="type"[...]

you will get a null reference exception because of the erroneous quotes.

Instead of throwing, it should not bind that data - and should fail validation if it is present