RuleValidation Class

Validates expression conditions.

Namespace: System.Workflow.Activities.Rules
Assembly: System.Workflow.Activities (in system.workflow.activities.dll)

public class RuleValidation
public class RuleValidation
public class RuleValidation
Not applicable.

The following code creates an invalid condition. It then attempts to validate the condition, and displays any errors that result.

// create an invalid condition ("abc" < true)
CodeBinaryOperatorExpression invalidCompare = new CodeBinaryOperatorExpression();
invalidCompare.Left = new CodePrimitiveExpression("abc");
invalidCompare.Operator = CodeBinaryOperatorType.LessThan;
invalidCompare.Right = new CodePrimitiveExpression(true);
RuleExpressionCondition condition = new RuleExpressionCondition();
condition.Expression = invalidCompare;

// create a validator for this condition
// since we are not using "this" in the condition, the type isn't used
RuleValidation validation = new RuleValidation(this.GetType(), null);

// see if the condition validates
if (!condition.Validate(validation))
    // there were errors, so display them
    foreach (ValidationError error in validation.Errors)

Running this code produces the following error:

Relational operator "LessThan" cannot be used on operands of types "string" and "bool".


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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions