ValidationAttribute.Validate Method

Determines whether the specified object is valid and throws a ValidationException if the object is not valid.

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

public void Validate(
	Object value,
	ValidationContext validationContext
)

Parameters

value
Type: System.Object
The object to validate.
validationContext
Type: System.ComponentModel.DataAnnotations.ValidationContext
An object that contains information about the validation request.

ExceptionCondition
ArgumentNullException

validationContext is null.

ValidationException

value is not valid.

When you create a class that derives from the ValidationAttribute class, override the IsValid method to provide the customized validation logic. The Validate method calls the IsValid method to determine if the value is valid.

Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: