ValidateValue Method
Collapse the table of content
Expand the table of content

Validator.ValidateValue Method

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)

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.

ExceptionCondition
ArgumentNullException

validationContext is null.

ValidationException

value is not valid.

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.

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:
© 2016 Microsoft