ValidationAttribute.GetValidationResult(Object, ValidationContext) 方法

定義

檢查指定的值在目前的驗證屬性方面是否有效。Checks whether the specified value is valid with respect to the current validation attribute.

public:
 System::ComponentModel::DataAnnotations::ValidationResult ^ GetValidationResult(System::Object ^ value, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext);
public System.ComponentModel.DataAnnotations.ValidationResult GetValidationResult (object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext);
public System.ComponentModel.DataAnnotations.ValidationResult? GetValidationResult (object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext);
member this.GetValidationResult : obj * System.ComponentModel.DataAnnotations.ValidationContext -> System.ComponentModel.DataAnnotations.ValidationResult
Public Function GetValidationResult (value As Object, validationContext As ValidationContext) As ValidationResult

參數

value
Object

要驗證的值。The value to validate.

validationContext
ValidationContext

有關驗證作業的內容資訊。The context information about the validation operation.

傳回

ValidationResult

ValidationResult 類別的執行個體。An instance of the ValidationResult class.

例外狀況

目前的屬性格式不正確。The current attribute is malformed.

validationContextnullvalidationContext is null.

衍生類別尚未實作 IsValid(Object, ValidationContext)IsValid(Object, ValidationContext) has not been implemented by a derived class.

備註

GetValidationResult方法會檢查有效性,而不擲回例外狀況。The GetValidationResult method checks validity without throwing an exception.

適用於

另請參閱