This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Discuss adding server side validation to value type model properties by default. #2776
Closed
Description
Today in MVC6 having the following model:
public class Person
{
public int Id { get; set; }
}
Will result in client side validation with 0 server side validation (unless specifying BindingBehaviorAttribute
with BindingBehavior.Required
).
This differs from what happened in MVC5; model state would be invalid due to server side validation opting in ValueType
properties. However, in WebAPI not providing a value for a ValueType
property when model binding was 100% ok and did not result in any ModelState
errors.
Given the different behavior in the old MVC/WebAPI systems we should discuss the right approach for this in MVC6.
Related conversation that spurred this: #2720 (comment)