Rules Syntax

Table of Contents

Basics

A rule can either be defined as a single line expression (Expression Syntax) or as a multi line script (Script Syntax).

The expressions and scripts are defined in C# (C# Language Reference).

Expression Syntax

The expression syntax is used for quickly defining simple validation rules.

  • Every expression must start with an equal sign (=).
  • An expression must return either true or false.

Examples:

=Data("Gender").IsNotEmpty

or

=Data("Gender").String == "M" || Data("Gender").String == "F"

Script Syntax

Use the script syntax when your intend is to build a more complex rule that better gets broken down into multiple lines of code.

  • The script must end with a return instruction that returns either true or false.
  • Each line of the script must be terminated by a semicolon (;) how it’s always done in C#.

Example:

var gender = Data("Gender").String;
var allowedValues = new List<string>() { "M", "F" };
return allowedValues.Contains(gender);

or

var age = DateTime.Today.Year - Data("BirthDate").DateTime.Year;
var actualVacationDays = (double)Data("VacationHours").Decimal / 8.5;

var availableVacationDays = 0;
if (age <= 25) {
  availableVacationDays = 25;
}
else {
  availableVacationDays = 20;
}

return actualVacationDays == availableVacationDays;

Functionallity

You can use most of the features of the .NET Framework 4.6 and the syntax-features of C# 6.0.

We added additional functions that makes it easier and more efficient to work with the probe data.

Data("Column-Name")
Using the Data(…) function, you can access a column of the probes dataset directly by its name. Because the value of a column in the current row can be of any allowed data type, you must use one of the following Properties to access the value.

  • Data("Column-Name").String
    Returns the columns value as a character string. The function returns a .NET object of the type System.String. Therefore you can use all functions and properties defined on this type.
  • Data("Column-Name").Integer
    Returns the columns value as a 32 bit integer value. The function returns a .NET object of the type System.Int32. Therefore you can use all functions and properties defined on this type.
  • Data("Column-Name").Long
    Returns the columns value as a 64 bit integer value. The function returns a .NET object of the type System.Int64. Therefore you can use all functions and properties defined on this type.
  • Data("Column-Name").Short
    Returns the columns value as a 16 bit integer value. The function returns a .NET object of the type System.Int16. Therefore you can use all functions and properties defined on this type.
  • Data("Column-Name").Decimal
    Returns the columns value as a decimal value. The function returns a .NET object of the type System.Decimal. Therefore you can use all functions and properties defined on this type.
  • Data("Column-Name").Boolean
    Returns the columns value as a boolean value. The function returns a .NET object of the type System.Boolean. Therefore you can use all functions and properties defined on this type.
  • Data("Column-Name").DateTime
    Returns the columns value as a DateTime value. The function returns a .NET object of the type System.DateTime. Therefore you can use all functions and properties defined on this type.
  • Data("Column-Name").Convert<TYPE>()
    Use this function to convert a column-value into any .NET type that implements the IConvertible interface. Replace the placeholder TYPE by the fullqualified name of the target type.
  • Data("Column-Name").IsNull
    Returns true when the field doesn’t contain any value (=NULL). There is also a Data("Column-Name").IsNotNull function you can use to do the vice versa.
  • Data("Column-Name").IsEmpty
    Returns true when the field doesn’t contain any value (=NULL) or when it contains an empty string (“”). There is also a Data("Column-Name").IsNotEmpty function you can use to do the vice versa.
  • Data("Column-Name").IsNumeric
    Returns true when the field contains a numeric value. There is also a Data("Column-Name").IsNotNumeric function you can use to do the vice versa.