Validator.TryValidateProperty Metod

Definition

Verifierar egenskapen.

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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")]
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
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of validationContext.ObjectType cannot be statically discovered.")>]
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

Parametrar

value
Object

Värdet som ska verifieras.

validationContext
ValidationContext

Kontexten som beskriver egenskapen som ska verifieras.

validationResults
ICollection<ValidationResult>

En samling för att lagra varje misslyckad validering.

Returer

trueom egenskapen verifierar; annars . false

Attribut

Undantag

value kan inte tilldelas egenskapen.

-eller-

value är null.

Egenskapen MemberNamevalidationContext för är inte en giltig egenskap.

Kommentarer

Den här metoden testar varje ValidationAttribute instans som är associerad med egenskapen som identifieras av parametern validationContext .

Gäller för