Validator 类

定义

定义一个帮助器类,在与对象、属性和方法关联的 ValidationAttribute 特性中包含此类时,可使用此类来验证这些项。Defines a helper class that can be used to validate objects, properties, and methods when it is included in their associated ValidationAttribute attributes.

public ref class Validator abstract sealed
public static class Validator
type Validator = class
Public Class Validator
继承
Validator

方法

TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>)

通过使用验证上下文和验证结果集合,确定指定的对象是否有效。Determines whether the specified object is valid using the validation context and validation results collection.

TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>, Boolean)

通过使用验证上下文、验证结果集合和用于指定是否验证所有属性的值,确定指定的对象是否有效。Determines whether the specified object is valid using the validation context, validation results collection, and a value that specifies whether to validate all properties.

TryValidateProperty(Object, ValidationContext, ICollection<ValidationResult>)

验证属性。Validates the property.

TryValidateValue(Object, ValidationContext, ICollection<ValidationResult>, IEnumerable<ValidationAttribute>)

返回一个值,该值指示所指定值对所指定特性是否有效。Returns a value that indicates whether the specified value is valid with the specified attributes.

ValidateObject(Object, ValidationContext)

使用验证上下文确定指定的对象是否有效。Determines whether the specified object is valid using the validation context.

ValidateObject(Object, ValidationContext, Boolean)

通过使用验证上下文和用于指定是否验证所有属性的值,确定指定的对象是否有效。Determines whether the specified object is valid using the validation context, and a value that specifies whether to validate all properties.

ValidateProperty(Object, ValidationContext)

验证属性。Validates the property.

ValidateValue(Object, ValidationContext, IEnumerable<ValidationAttribute>)

验证指定的特性。Validates the specified attributes.

适用于