ValidationErrorCollection.HasErrors Property

Definition

Indicates whether the collection contains ValidationError objects that indicate compilation errors.

C#
public bool HasErrors { get; }

Property Value

true if the activity has generated validation errors; otherwise, false.

Examples

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

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

C#
public class SendEmailValidator : System.Workflow.ComponentModel.Compiler.ActivityValidator
{
    // Define private constants for the Validation Errors
    private const int InvalidToAddress = 1;
    private const int InvalidFromAddress = 2;
    private const int InvalidSMTPPort = 3;

    //customizing the default activity validation
    public override ValidationErrorCollection ValidateProperties(ValidationManager manager, object obj)
    {

        // Create a new collection for storing the validation errors
        ValidationErrorCollection validationErrors = base.ValidateProperties(manager, obj);

        SendEmailActivity activity = obj as SendEmailActivity;
        if (activity != null)
        {
            // Validate the Email and SMTP Properties
            this.ValidateEmailProperties(validationErrors, activity);
            this.ValidateSMTPProperties(validationErrors, activity);
        }
        return validationErrors;
    }

Remarks

If an Activity has generated a warning, the warning is considered an error in the context of this property.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1