Validator.TryValidateObject 메서드

정의

지정된 개체가 유효한지 여부를 확인합니다.

오버로드

Name Description
TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>)

유효성 검사 컨텍스트 및 유효성 검사 결과 컬렉션을 사용하여 지정된 개체가 유효한지 여부를 확인합니다.

TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>, Boolean)

유효성 검사 컨텍스트, 유효성 검사 결과 컬렉션 및 모든 속성의 유효성을 검사할지 여부를 지정하는 값을 사용하여 지정된 개체가 유효한지 여부를 확인합니다.

TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>)

Source:
Validator.cs
Source:
Validator.cs
Source:
Validator.cs
Source:
Validator.cs
Source:
Validator.cs

유효성 검사 컨텍스트 및 유효성 검사 결과 컬렉션을 사용하여 지정된 개체가 유효한지 여부를 확인합니다.

public:
 static bool TryValidateObject(System::Object ^ instance, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext, System::Collections::Generic::ICollection<System::ComponentModel::DataAnnotations::ValidationResult ^> ^ validationResults);
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> validationResults);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults);
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults);
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> -> bool
Public Shared Function TryValidateObject (instance As Object, validationContext As ValidationContext, validationResults As ICollection(Of ValidationResult)) As Boolean

매개 변수

instance
Object

유효성을 검사할 개체입니다.

validationContext
ValidationContext

유효성을 검사할 개체를 설명하는 컨텍스트입니다.

validationResults
ICollection<ValidationResult>

실패한 각 유효성 검사를 저장할 컬렉션입니다.

반품

true개체의 유효성을 검사하는 경우 그렇지 않으면 . false

특성

예외

instancenull입니다.

instance은 켜ObjectInstance기와 validationContext일치하지 않습니다.

설명

이 메서드는 개체 형식에 연결된 각 ValidationAttribute 인스턴스를 평가합니다. 또한 표시된 RequiredAttribute 각 속성이 제공되는지 여부를 확인합니다. 개체의 속성 값은 재귀적으로 유효성을 검사하지 않습니다.

적용 대상

TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>, Boolean)

Source:
Validator.cs
Source:
Validator.cs
Source:
Validator.cs
Source:
Validator.cs
Source:
Validator.cs

유효성 검사 컨텍스트, 유효성 검사 결과 컬렉션 및 모든 속성의 유효성을 검사할지 여부를 지정하는 값을 사용하여 지정된 개체가 유효한지 여부를 확인합니다.

public:
 static bool TryValidateObject(System::Object ^ instance, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext, System::Collections::Generic::ICollection<System::ComponentModel::DataAnnotations::ValidationResult ^> ^ validationResults, bool validateAllProperties);
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> validationResults, bool validateAllProperties);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, bool validateAllProperties);
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, bool validateAllProperties);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, bool validateAllProperties);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, bool validateAllProperties);
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> * bool -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> * bool -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> * bool -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> * bool -> bool
Public Shared Function TryValidateObject (instance As Object, validationContext As ValidationContext, validationResults As ICollection(Of ValidationResult), validateAllProperties As Boolean) As Boolean

매개 변수

instance
Object

유효성을 검사할 개체입니다.

validationContext
ValidationContext

유효성을 검사할 개체를 설명하는 컨텍스트입니다.

validationResults
ICollection<ValidationResult>

실패한 각 유효성 검사를 저장할 컬렉션입니다.

validateAllProperties
Boolean

true 모든 속성의 유효성을 검사하려면 다음을 수행합니다. 이면 false필요한 특성만 유효성을 검사합니다.

반품

true개체의 유효성을 검사하는 경우 그렇지 않으면 . false

특성

예외

instancenull입니다.

instance은 켜ObjectInstance기와validationContext일치하지 않습니다.

설명

이 메서드는 개체 형식에 연결된 각 ValidationAttribute 인스턴스를 평가합니다. 또한 표시된 RequiredAttribute 각 속성이 제공되는지 여부를 확인합니다. 있는 경우 validateAllPropertiestrue 개체의 속성 값의 유효성을 검사하지만 속성에서 반환된 개체의 속성은 재귀적으로 유효성을 검사하지 않습니다.

적용 대상