ValidationAttribute.IsValid 方法

定義

檢查指定的物件是否有效。

多載

IsValid(Object)

判斷指定的物件值是否有效。

IsValid(Object, ValidationContext)

根據目前的驗證屬性,驗證指定的值。

IsValid(Object)

來源:
ValidationAttribute.cs
來源:
ValidationAttribute.cs
來源:
ValidationAttribute.cs

判斷指定的物件值是否有效。

public:
 virtual bool IsValid(System::Object ^ value);
public:
 abstract bool IsValid(System::Object ^ value);
public virtual bool IsValid (object value);
public virtual bool IsValid (object? value);
public abstract bool IsValid (object value);
abstract member IsValid : obj -> bool
override this.IsValid : obj -> bool
abstract member IsValid : obj -> bool
Public Overridable Function IsValid (value As Object) As Boolean
Public MustOverride Function IsValid (value As Object) As Boolean

參數

value
Object

要驗證的物件值。

傳回

如果指定的值有效,則為 true,否則為 false

例外狀況

目前的屬性格式不正確。

衍生類別尚未實作任何 IsValid 多載。

備註

如果您繼承自 ValidationAttribute 類別,則必須在此方法中實作驗證邏輯。

適用於

IsValid(Object, ValidationContext)

來源:
ValidationAttribute.cs
來源:
ValidationAttribute.cs
來源:
ValidationAttribute.cs

根據目前的驗證屬性,驗證指定的值。

protected:
 virtual System::ComponentModel::DataAnnotations::ValidationResult ^ IsValid(System::Object ^ value, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext);
protected virtual System.ComponentModel.DataAnnotations.ValidationResult IsValid (object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext);
protected virtual System.ComponentModel.DataAnnotations.ValidationResult? IsValid (object? value, System.ComponentModel.DataAnnotations.ValidationContext validationContext);
abstract member IsValid : obj * System.ComponentModel.DataAnnotations.ValidationContext -> System.ComponentModel.DataAnnotations.ValidationResult
override this.IsValid : obj * System.ComponentModel.DataAnnotations.ValidationContext -> System.ComponentModel.DataAnnotations.ValidationResult
Protected Overridable Function IsValid (value As Object, validationContext As ValidationContext) As ValidationResult

參數

value
Object

要驗證的值。

validationContext
ValidationContext

有關驗證作業的內容資訊。

傳回

ValidationResult 類別的執行個體。

例外狀況

目前的屬性格式不正確。

另請參閱

適用於