Validator.ValidateValue Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Determines whether a specified value is valid against a collection of validation attributes and throws a ValidationException if the value is not valid.
Namespace: System.ComponentModel.DataAnnotations
Assembly: System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)
Syntax
'Declaration
Public Shared Sub ValidateValue ( _
value As Object, _
validationContext As ValidationContext, _
validationAttributes As IEnumerable(Of ValidationAttribute) _
)
public static void ValidateValue(
Object value,
ValidationContext validationContext,
IEnumerable<ValidationAttribute> validationAttributes
)
Parameters
- value
Type: System.Object
The value to validate.
- validationContext
Type: System.ComponentModel.DataAnnotations.ValidationContext
An object that contains information about the validation request.
- validationAttributes
Type: System.Collections.Generic.IEnumerable<ValidationAttribute>
The collection of validation attributes to use to determine if value is valid.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | validationContext is nulla null reference (Nothing in Visual Basic). |
ValidationException | value is not valid. |
Remarks
The ValidateValue method tests each validation attribute in the validationAttributes parameter against the value parameter. If a RequiredAttribute attribute is included, the RequiredAttribute attribute is evaluated first.
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.
See Also