ValidationAttribute.Validate ValidationAttribute.Validate ValidationAttribute.Validate ValidationAttribute.Validate Method

Definition

Validates the specified object.

Overloads

Validate(Object, ValidationContext) Validate(Object, ValidationContext) Validate(Object, ValidationContext)

Validates the specified object.

Validate(Object, String) Validate(Object, String) Validate(Object, String) Validate(Object, String)

Validates the specified object.

Validate(Object, ValidationContext) Validate(Object, ValidationContext) Validate(Object, ValidationContext)

Validates the specified object.

public:
 void Validate(System::Object ^ value, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext);
public void Validate (object value, System.ComponentModel.DataAnnotations.ValidationContext validationContext);
member this.Validate : obj * System.ComponentModel.DataAnnotations.ValidationContext -> unit

Parameters

value
Object Object Object Object

The object to validate.

validationContext
ValidationContext ValidationContext ValidationContext ValidationContext

The ValidationContext object that describes the context where the validation checks are performed. This parameter cannot be null.

Exceptions

Remarks

This method calls the IsValid method to determine whether the object that is specified by the value parameter is valid. If the Validate method returns false, this method calls the FormatErrorMessage method to get a localized message that states the problem. It then throws a ValidationException exception.

Validate(Object, String) Validate(Object, String) Validate(Object, String) Validate(Object, String)

Validates the specified object.

public:
 void Validate(System::Object ^ value, System::String ^ name);
public void Validate (object value, string name);
member this.Validate : obj * string -> unit
Public Sub Validate (value As Object, name As String)

Parameters

value
Object Object Object Object

The value of the object to validate.

name
String String String String

The name to include in the error message.

Exceptions

Remarks

This method validates the value of the object or property on which the ValidationAttribute attribute is declared. It calls the IsValid method and passes value as a parameter. If validation fails, a ValidationException exception is thrown.

Applies to