From 63467db347d6b9939b395550f2aca75cd9eeb3a9 Mon Sep 17 00:00:00 2001 From: Luke Latham Date: Thu, 28 Sep 2017 10:45:28 -0500 Subject: [PATCH] React to feedback --- aspnetcore/mvc/models/validation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aspnetcore/mvc/models/validation.md b/aspnetcore/mvc/models/validation.md index 3b3a0ec03b..40b8773d6d 100644 --- a/aspnetcore/mvc/models/validation.md +++ b/aspnetcore/mvc/models/validation.md @@ -61,12 +61,12 @@ There may be instances where you need more features than built-in attributes pro Non-nullable [value types](/dotnet/csharp/language-reference/keywords/value-types) (such as `decimal`, `int`, `float`, and `DateTime`) are inherently required and don't need the `Required` attribute. The app performs no server-side validation checks for non-nullable types that are marked `Required`. -MVC model binding, which isn't concerned with validation and validation attributes, rejects a form field submission containing a missing value or whitespace for a non-nullable type. Model binding usually ignores missing data for non-nullable types, where the form field is absent from the incoming form data. - -Client-side validation requires a value for a form field that corresponds to a model property that you've marked `Required` and for a non-nullable type property that you haven't marked `Required`. `Required` can be used to control the client-side validation error message. +MVC model binding, which isn't concerned with validation and validation attributes, rejects a form field submission containing a missing value or whitespace for a non-nullable type. In the absence of a `BindRequired` attribute on the target property, model binding ignores missing data for non-nullable types, where the form field is absent from the incoming form data. The [BindRequired attribute](/aspnet/core/api/microsoft.aspnetcore.mvc.modelbinding.bindrequiredattribute) (also see [Customize model binding behavior with attributes](xref:mvc/models/model-binding#customize-model-binding-behavior-with-attributes)) is useful to ensure form data is complete. When applied to a property, the model binding system requires a value for that property. When applied to a type, the model binding system requires values for all of the properties of that type. +Client-side validation requires a value for a form field that corresponds to a model property that you've marked `Required` and for a non-nullable type property that you haven't marked `Required`. `Required` can be used to control the client-side validation error message. + When you use a [Nullable\ type](/dotnet/csharp/programming-guide/nullable-types/) (for example, `decimal?` or `System.Nullable`) and mark it `Required`, a server-side validation check is performed as if the property were a standard nullable type (for example, a `string`). ## Model State