This documentation is archived and is not being maintained.

ValidationError Class

Represents the base class for all validation errors.

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

[SerializableAttribute]
public sealed class ValidationError

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));

    }
}

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

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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Show: