Compartir a través de


Validator Class

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

Provides members to help validate objects and members using values from the associated ValidationAttribute attribute.

Inheritance Hierarchy

System.Object
  System.ComponentModel.DataAnnotations.Validator

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

Syntax

'Declaration
Public NotInheritable Class Validator
public static class Validator

The Validator type exposes the following members.

Methods

  Name Description
Public methodStatic member TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>) Determines whether the specified object is valid.
Public methodStatic member TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>, Boolean) Determines whether the specified object is valid and, if requested, validates all of the properties of the object.
Public methodStatic member TryValidateProperty Determines whether the specified property value is valid.
Public methodStatic member TryValidateValue Determines whether a specified value is valid against a collection of validation attributes.
Public methodStatic member ValidateObject(Object, ValidationContext) Determines whether the specified object is valid and throws a ValidationException if the object is not valid.
Public methodStatic member ValidateObject(Object, ValidationContext, Boolean) Determines whether the specified object is valid and, if requested, whether all of the properties on the object are valid, and throws a ValidationException if the object is not valid.
Public methodStatic member ValidateProperty Determines whether the specified property value is valid and throws a ValidationException if the property is not valid.
Public methodStatic member ValidateValue Determines whether a specified value is valid against a collection of validation attributes and throws a ValidationException if the value is not valid.

Top

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.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.