Basic Validation

This topic applies to Windows Workflow Foundation 4 (WF4).

This sample consists of an activity, CreateProduct, which validates that its Cost argument is smaller than or equal to its Price argument.

Sample Details

There are two authors that use validation, the activity author (creates the validation logic for the activity) and the workflow author that calls validation services on a specific workflow. In this scenario, the activity author wants to enforce that every instance of his activity must have a smaller or equal cost than that of the price.

The activity author (inside the activity) must:

  • Create a constraint (PriceGreaterThanCost). This is where all the validation logic resides.

  • Override OnGetConstraints and add the constraint (PriceGreaterThanCost) to the constraints IList.

The workflow author (main program) must:

To set up, build, and run the sample

  1. Open the BasicValidation.sln sample solution in Visual Studio 2010.

  2. Build and run the solution.

Dd759026.Important(en-us,VS.100).gif Note:
The samples may already be installed on your computer. Check for the following (default) directory before continuing.

<InstallDrive>:\WF_WCF_Samples

If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.

<InstallDrive>:\WF_WCF_Samples\WF\Basic\Validation\BasicValidation