Bewerken

Delen via


Validator.TryValidateProperty 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);
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
Public Shared Function TryValidateProperty (value As Object, validationContext As ValidationContext, validationResults As ICollection(Of ValidationResult)) As Boolean

Parameters

value
Object

The value to validate.

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