RequiredBindingMetadataProvider Class
Provides binding metadata based on the presence of the System.ComponentModel.DataAnnotations.RequiredAttribute on model properties.
public class RequiredBindingMetadataProvider : Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IBindingMetadataProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IMetadataDetailsProviderInheritance System.Object → RequiredBindingMetadataProvider
Implements Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IBindingMetadataProvider, Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IMetadataDetailsProvider
Remarks
This class implements the Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IBindingMetadataProvider interface and checks if a model property is annotated with the System.ComponentModel.DataAnnotations.RequiredAttribute. If so, it sets the binding metadata to indicate that binding is required for that property.
Methods
RequiredBindingMetadataProvider.CreateBindingMetadata(BindingMetadataProviderContext) Method
Creates binding metadata for a given context. If a model property is marked with System.ComponentModel.DataAnnotations.RequiredAttribute, this method sets the binding metadata to require binding for that property.
public void CreateBindingMetadata(Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.BindingMetadataProviderContext context);Parameters
context Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.BindingMetadataProviderContext
The context for the binding metadata provider.
Implements CreateBindingMetadata(BindingMetadataProviderContext)
Remarks
The method checks for the presence of System.ComponentModel.DataAnnotations.RequiredAttribute in the property attributes of the context. If found, it sets Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.BindingMetadata.IsBindingRequired to true, enforcing the requirement for binding.