Skip to content

RuleChecks

Static class in Oadm.Sdk.Events · Oadm.Sdk.dll

The rules of field checks shared by the server and the rule dialog (SDK 0.9.0).

public static class RuleChecks
static string Describe(RuleCheck check, string fieldName, EventValueKind kind)

The check in one short phrase: “Temperature > 40”, “Door is yes”, “State equals active”.

static bool Fits(RuleCheckOperator op, EventValueKind kind)

Whether op can check a field of kind.

static bool IsNumeric(RuleCheckOperator op, EventValueKind kind)

Whether the check compares numbers (every number operator, and = / ≠ on a number field).

static bool IsYes(string? text)

“true”, “1” and “yes” (any case) count as yes.

static string Label(RuleCheckOperator op, EventValueKind kind)

The operator in the Operator select of the rule dialog and its list: a number operator as its symbol and words (“= equals”, “≠ does not equal”, “> greater than”, “≥ greater than or equal”, “< less than”, “≤ less than or equal”), every other one as RuleChecks.Text.

static bool NeedsValue(RuleCheckOperator op)

False for yes / no: they have no value.

static IReadOnlyList<RuleCheckOperator> OperatorsFor(EventValueKind kind)

The operators a field of kind offers, in the order of the dialog.

static string? Problem(RuleCheck check, IReadOnlyList<EventField> fields)

The problem of one check against the fields of its event, or null: the field must be one of the event’s checkable fields (EventField.Filter), the operator must fit its kind, the value must be there (a number for number checks) and at most RuleChecks.MaxValueLength characters long. An older equals filter (RuleCheck.IsLegacy) only needs a value the event declares, as before field checks. “Temperature: enter a number, e.g. 21.5.”

static string Text(RuleCheckOperator op, EventValueKind kind)

The operator in the dialog: “equals”, “does not equal”, “contains”, “starts with”, “=”, “≠”, “>”, “≥”, “<”, “≤”, “is yes”, “is no”.

static bool TooMany(IReadOnlyCollection<RuleCheck> checks)

Whether the checks of a condition are too many: more than RuleChecks.MaxPerCondition, unless every one is an older equals filter (RuleCheck.IsLegacy: rules of older versions had no limit and keep working unchanged).

static bool TryParseNumber(string? text, out double value)

A finite number in invariant culture (“21.5”, “-3”, “1e3”).

static string? ValueProblem(RuleCheckOperator op, EventValueKind kind, string? value)

The problem of the value of a check, or null (also the rule of the value box of the dialog).

const int MaxPerCondition = 5

Most checks per event condition.

const int MaxValueLength = 200

Longest value of a check.

const string NoSuchValueText = "The event no longer has this value."

A check on a value the event does not have (any more), or not one a check can compare.

static readonly string TooManyText

More than RuleChecks.MaxPerCondition checks on one condition.