November Happy Hour will be moved to Thursday December 5th.

Class DataAnnotationsValidator<T>

Base class for validator classes that does validation against attributes specified in System.ComponentModel.DataAnnotations

Inheritance
System.Object
DataAnnotationsValidator<T>
Implements
Namespace: EPiServer.Validation
Assembly: EPiServer.Framework.dll
Version: 12.0.3
Syntax
public abstract class DataAnnotationsValidator<T> : Object, IValidate<T>, IValidate
Type Parameters
Name Description
T

Constructors

DataAnnotationsValidator()

Initializes a new instance of the DataAnnotationsValidator<T> class.

Declaration
protected DataAnnotationsValidator()

DataAnnotationsValidator(LocalizationService)

Initializes a new instance of the DataAnnotationsValidator<T> class.

Declaration
protected DataAnnotationsValidator(LocalizationService localizationService)
Parameters
Type Name Description
LocalizationService localizationService

Properties

IgnoredAttributes

Gets or sets attribute type that should not be part of validation.

Declaration
public virtual IEnumerable<Type> IgnoredAttributes { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.Type>

The ignored attributes.

Remarks

Default implementation returns empty enumeration.

Methods

GetDisplayName(PropertyDescriptor, Object)

Gets the display name for the propertyDescriptor on instance.

Declaration
protected virtual string GetDisplayName(PropertyDescriptor propertyDescriptor, object instance)
Parameters
Type Name Description
System.ComponentModel.PropertyDescriptor propertyDescriptor

The property to get the display name for.

System.Object instance

The object instance that propertyDescriptor is defined on.

Returns
Type Description
System.String

A translated display name if any translation exists.

Validate(T)

Validates the specified instance.

Declaration
public virtual IEnumerable<ValidationError> Validate(T instance)
Parameters
Type Name Description
T instance

The instance.

Returns
Type Description
System.Collections.Generic.IEnumerable<ValidationError>

Implements

Extension Methods