This documentation is archived and is not being maintained.

ValidationAttribute.Validate Method

Validates an object or property on which the ValidationAttribute is declared.

Namespace:  System.ComponentModel.DataAnnotations
Assembly:  System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)

public void Validate(
	Object value,
	string name
)

Parameters

value
Type: System.Object

The value of the object on which a ValidationAttribute is declared.

name
Type: System.String

The name of the object or data field on which a ValidationAttribute is declared.

ExceptionCondition
ValidationException

Value is not valid.

This method validates the value of the object or property on which the ValidationAttribute is declared. It calls the IsValid method using value as parameter. If the call fails, a ValidationException is thrown.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1
Show: