MvcOptions.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value that determines if the inference of RequiredAttribute for
properties and parameters of non-nullable reference types is suppressed. If false
(the default), then all non-nullable reference types will behave as-if [Required]
has
been applied. If true
, this behavior will be suppressed; nullable reference types and
non-nullable reference types will behave the same for the purposes of validation.
public:
property bool SuppressImplicitRequiredAttributeForNonNullableReferenceTypes { bool get(); void set(bool value); };
public bool SuppressImplicitRequiredAttributeForNonNullableReferenceTypes { get; set; }
member this.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes : bool with get, set
Public Property SuppressImplicitRequiredAttributeForNonNullableReferenceTypes As Boolean
Property Value
Remarks
This option controls whether MVC model binding and validation treats nullable and non-nullable reference types differently.
By default, MVC will treat a non-nullable reference type parameters and properties as-if [Required]
has been applied, resulting in validation errors when no value was bound.
MVC does not support non-nullable reference type annotations on type arguments and type parameter constraints. The framework will not infer any validation attributes for generic-typed properties or collection elements.