Table of Contents

Class DataAnnotationsModelValidatorProvider

Namespace
System.Web.Mvc
Assembly
System.Web.Mvc.dll

Implements the default validation provider for ASP.NET MVC.

public class DataAnnotationsModelValidatorProvider : AssociatedValidatorProvider
Inheritance
DataAnnotationsModelValidatorProvider
Inherited Members

Constructors

DataAnnotationsModelValidatorProvider()

Initializes a new instance of the DataAnnotationsModelValidatorProvider class.

public DataAnnotationsModelValidatorProvider()

Properties

AddImplicitRequiredAttributeForValueTypes

Gets or sets a value that indicates whether non-nullable value types are required.

public static bool AddImplicitRequiredAttributeForValueTypes { get; set; }

Property Value

bool

true if non-nullable value types are required; otherwise, false.

Methods

GetValidators(ModelMetadata, ControllerContext, IEnumerable<Attribute>)

Gets a list of validators.

protected override IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context, IEnumerable<Attribute> attributes)

Parameters

metadata ModelMetadata

The metadata.

context ControllerContext

The context.

attributes IEnumerable<Attribute>

The list of validation attributes.

Returns

IEnumerable<ModelValidator>

A list of validators.

RegisterAdapter(Type, Type)

Registers an adapter to provide client-side validation.

public static void RegisterAdapter(Type attributeType, Type adapterType)

Parameters

attributeType Type

The type of the validation attribute.

adapterType Type

The type of the adapter.

RegisterAdapterFactory(Type, DataAnnotationsModelValidationFactory)

Registers an adapter factory for the validation provider.

public static void RegisterAdapterFactory(Type attributeType, DataAnnotationsModelValidationFactory factory)

Parameters

attributeType Type

The type of the attribute.

factory DataAnnotationsModelValidationFactory

The factory that will be used to create the ModelValidator object for the specified attribute.

RegisterDefaultAdapter(Type)

Registers the default adapter.

public static void RegisterDefaultAdapter(Type adapterType)

Parameters

adapterType Type

The type of the adapter.

RegisterDefaultAdapterFactory(DataAnnotationsModelValidationFactory)

Registers the default adapter factory.

public static void RegisterDefaultAdapterFactory(DataAnnotationsModelValidationFactory factory)

Parameters

factory DataAnnotationsModelValidationFactory

The factory that will be used to create the ModelValidator object for the default adapter.

RegisterDefaultValidatableObjectAdapter(Type)

Registers an adapter to provide default object validation.

public static void RegisterDefaultValidatableObjectAdapter(Type adapterType)

Parameters

adapterType Type

The type of the adapter.

RegisterDefaultValidatableObjectAdapterFactory(DataAnnotationsValidatableObjectAdapterFactory)

Registers an adapter factory for the default object validation provider.

public static void RegisterDefaultValidatableObjectAdapterFactory(DataAnnotationsValidatableObjectAdapterFactory factory)

Parameters

factory DataAnnotationsValidatableObjectAdapterFactory

The factory.

RegisterValidatableObjectAdapter(Type, Type)

Registers an adapter to provide object validation.

public static void RegisterValidatableObjectAdapter(Type modelType, Type adapterType)

Parameters

modelType Type

The type of the model.

adapterType Type

The type of the adapter.

RegisterValidatableObjectAdapterFactory(Type, DataAnnotationsValidatableObjectAdapterFactory)

Registers an adapter factory for the object validation provider.

public static void RegisterValidatableObjectAdapterFactory(Type modelType, DataAnnotationsValidatableObjectAdapterFactory factory)

Parameters

modelType Type

The type of the model.

factory DataAnnotationsValidatableObjectAdapterFactory

The factory.