ValidationError Class

 

Represents the base class for all validation errors.

Namespace:   System.Workflow.ComponentModel.Compiler
Assembly:  System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)

System.Object
  System.Workflow.ComponentModel.Compiler.ValidationError

[SerializableAttribute]
public sealed class ValidationError

NameDescription
System_CAPS_pubmethodValidationError(String, Int32)

Initializes a new instance of the ValidationError class; initializes the error text and error numbers for this instance.

System_CAPS_pubmethodValidationError(String, Int32, Boolean)

Initializes a new instance of the ValidationError class, initializes the error text, error number and error type for this instance.

System_CAPS_pubmethodValidationError(String, Int32, Boolean, String)

Initializes a new instance of the ValidationError class, initializing the error text, the error number, the error type and the property name associated with the error.

NameDescription
System_CAPS_pubpropertyErrorNumber

Gets the error number of this instance.

System_CAPS_pubpropertyErrorText

Gets the error text for this instance.

System_CAPS_pubpropertyIsWarning

Gets a value that indicates whether this instance is a warning.

System_CAPS_pubpropertyPropertyName

Gets or sets the name of the property that failed to validate.

System_CAPS_pubpropertyUserData

Gets an IDictionary for the definition and storage of user-defined data related to this instance.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetNotSetValidationError(String)

Creates a new validation error defined for the error type of a property not being set.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Provides a string representation of this instance incorporating the error type (error or warning) the error number and the error text.(Overrides Object.ToString().)

System_CAPS_noteNote

This material discusses types and namespaces that are obsolete. For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

The following example shows how to create and manipulate validation errors as part of a custom validation routine.

This code example is part of the Send Mail SDK Sample and is from the SendEMailActivity.cs file. For more information, see Send Mail Activity.

private void ValidateEmailProperties(ValidationErrorCollection validationErrors, SendEmailActivity activity)
{
    // Validate the To property
    if (String.IsNullOrEmpty(activity.To))
    {
        validationErrors.Add(ValidationError.GetNotSetValidationError(SendEmailActivity.ToProperty.Name));

    }
    else if (!activity.To.Contains("@"))
    {
        validationErrors.Add(new ValidationError("Invalid To e-mail address", InvalidToAddress, false, SendEmailActivity.ToProperty.Name));

    }

    // Validate the From property
    if (String.IsNullOrEmpty(activity.From))
    {
        validationErrors.Add(ValidationError.GetNotSetValidationError(SendEmailActivity.FromProperty.Name));
    }
    else if (!activity.From.Contains("@"))
    {
        validationErrors.Add(new ValidationError("Invalid From e-mail address", InvalidFromAddress, false, SendEmailActivity.FromProperty.Name));

    }
}

.NET Framework
Available since 3.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: