Validator.TryValidateProperty(Object, ValidationContext, ICollection<ValidationResult>) Validator.TryValidateProperty(Object, ValidationContext, ICollection<ValidationResult>) Validator.TryValidateProperty(Object, ValidationContext, ICollection<ValidationResult>) Method

Definition

Validates the property.

public:
 static bool TryValidateProperty(System::Object ^ value, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext, System::Collections::Generic::ICollection<System::ComponentModel::DataAnnotations::ValidationResult ^> ^ validationResults);
public static bool TryValidateProperty (object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> validationResults);
static member TryValidateProperty : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> -> bool

Parameters

value
Object Object Object

The value to validate.

validationContext
ValidationContext ValidationContext ValidationContext

The context that describes the property to validate.

validationResults
ICollection<ValidationResult>

A collection to hold each failed validation.

Returns

true if the property validates; otherwise, false.

Exceptions

value cannot be assigned to the property.

-or-

value is null.

The MemberName property of validationContext is not a valid property.

Remarks

This method tests each ValidationAttribute instance that is associated with the property that is identified by the validationContext parameter.

Applies to