Baca dalam bahasa Inggris

Bagikan melalui


ValidationAttribute.Validate Method

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

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)

Syntax

'Declaration
Public Sub Validate ( _
    value As Object, _
    validationContext As ValidationContext _
)
public void Validate(
    Object value,
    ValidationContext validationContext
)

Parameters

Exceptions

Exception Condition
ArgumentNullException

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

ValidationException

value is not valid.

Remarks

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.

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.