Validator.ValidateObject Method

Definition

Determines whether the specified object is valid.

Overloads

ValidateObject(Object, ValidationContext)

Determines whether the specified object is valid using the validation context.

ValidateObject(Object, ValidationContext, Boolean)

Determines whether the specified object is valid using the validation context, and a value that specifies whether to validate all properties.

ValidateObject(Object, ValidationContext)

Determines whether the specified object is valid using the validation context.

public:
 static void ValidateObject(System::Object ^ instance, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext);
public static void ValidateObject (object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext);
static member ValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext -> unit
Public Shared Sub ValidateObject (instance As Object, validationContext As ValidationContext)

Parameters

instance
Object

The object to validate.

validationContext
ValidationContext

The context that describes the object to validate.

Exceptions

The object is not valid.

instance is null.

instance doesn't match the ObjectInstance on validationContext.

Remarks

This method evaluates each ValidationAttribute instance that is attached to the object type.

ValidateObject(Object, ValidationContext, Boolean)

Determines whether the specified object is valid using the validation context, and a value that specifies whether to validate all properties.

public:
 static void ValidateObject(System::Object ^ instance, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext, bool validateAllProperties);
public static void ValidateObject (object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, bool validateAllProperties);
static member ValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * bool -> unit
Public Shared Sub ValidateObject (instance As Object, validationContext As ValidationContext, validateAllProperties As Boolean)

Parameters

instance
Object

The object to validate.

validationContext
ValidationContext

The context that describes the object to validate.

validateAllProperties
Boolean

true to validate all properties; otherwise, false.

Exceptions

instance is not valid.

instance is null.

instance doesn't match the ObjectInstance on validationContext.

Remarks

This method evaluates each ValidationAttribute instance that is attached to the object type.

Applies to