ValidationAttribute.GetValidationResult Method

Determines whether the specified object is valid and returns an object that includes the results of the validation check.

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

'Declaration
Public Function GetValidationResult ( _
	value As Object, _
	validationContext As ValidationContext _
) As ValidationResult

Parameters

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

Return Value

Type: System.ComponentModel.DataAnnotations.ValidationResult
Success if the value is valid; otherwise, an instance of the ValidationResult class with the error message.

ExceptionCondition
ArgumentNullException

validationContext is Nothing.

When you create a class that derives from the ValidationAttribute class, override the IsValid method to provide the customized validation logic. The GetValidationResult 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: