Class DataAnnotationsModelValidatorProvider
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
ModelMetadataThe metadata.
context
ControllerContextThe 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
RegisterAdapterFactory(Type, DataAnnotationsModelValidationFactory)
Registers an adapter factory for the validation provider.
public static void RegisterAdapterFactory(Type attributeType, DataAnnotationsModelValidationFactory factory)
Parameters
attributeType
TypeThe type of the attribute.
factory
DataAnnotationsModelValidationFactoryThe 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
TypeThe type of the adapter.
RegisterDefaultAdapterFactory(DataAnnotationsModelValidationFactory)
Registers the default adapter factory.
public static void RegisterDefaultAdapterFactory(DataAnnotationsModelValidationFactory factory)
Parameters
factory
DataAnnotationsModelValidationFactoryThe 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
TypeThe type of the adapter.
RegisterDefaultValidatableObjectAdapterFactory(DataAnnotationsValidatableObjectAdapterFactory)
Registers an adapter factory for the default object validation provider.
public static void RegisterDefaultValidatableObjectAdapterFactory(DataAnnotationsValidatableObjectAdapterFactory factory)
Parameters
factory
DataAnnotationsValidatableObjectAdapterFactoryThe factory.
RegisterValidatableObjectAdapter(Type, Type)
Registers an adapter to provide object validation.
public static void RegisterValidatableObjectAdapter(Type modelType, Type adapterType)
Parameters
RegisterValidatableObjectAdapterFactory(Type, DataAnnotationsValidatableObjectAdapterFactory)
Registers an adapter factory for the object validation provider.
public static void RegisterValidatableObjectAdapterFactory(Type modelType, DataAnnotationsValidatableObjectAdapterFactory factory)
Parameters
modelType
TypeThe type of the model.
factory
DataAnnotationsValidatableObjectAdapterFactoryThe factory.