Поделиться через


ValidationAttribute.GetValidationResult Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

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

Parameters

Return Value

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

Exceptions

Exception Condition
ArgumentNullException

validationContext is nulla null reference (Nothing in Visual Basic).

Remarks

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.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

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