Condition Checkers

Condition Checkers

Conditions are set with set_condition tasks. Each checker evaluates a field and returns True or False.

Syntax:

- set_condition: [COND, checker, field, ...]

Use !COND to negate a condition in any task.

field_match

set_condition: [COND, field_match, fieldname, 'regexp']

True if fieldname value matches the regular expression pattern (Python re.search).

Example:

tasks:
# flag entries whose name starts with 'test'
- set_condition: [IS_TEST, field_match, name, '^test']
- field_set: [IS_TEST, status, ignored]

# discard entries with a status of 'deleted' or 'obsolete'
- set_condition: [OBSOLETE, field_match, status, '^(deleted|obsolete)$']
- discard: [OBSOLETE]

ge, gt, lt, le, eq, ne

set_condition: [COND, ge, field1, field2]
set_condition: [COND, gt, field1, field2]
set_condition: [COND, lt, field1, field2]
set_condition: [COND, le, field1, field2]
set_condition: [COND, eq, field1, field2]
set_condition: [COND, ne, field1, field2]

Compare two fields. Values are coerced in order: intfloatstr. This means numeric strings compare numerically ("10" > "9"), and ISO datetime strings (YYYY-MM-DD HH:MM:SS) compare chronologically.

Returns False if either field is missing.

Operator Meaning
ge field1 >= field2
gt field1 > field2
lt field1 < field2
le field1 <= field2
eq field1 == field2
ne field1 != field2

Example:

tasks:
# disable entries older than a reference date
- set_condition: [IS_OLD, lt, last_sync, cutoff_date]
- field_set: [IS_OLD, _action, disable]

# flag entries where count exceeded limit
- set_condition: [OVER_LIMIT, gt, count, max_count]
- field_set: [OVER_LIMIT, status, exceeded]

exists

set_condition: [COND, exists, field]

Returns True if field is present in the current data record, regardless of its value (even empty string). Returns False if the field is absent.

Example:

tasks:
- set_condition: [NO_OWNER, exists, owner]
- field_set: [!NO_OWNER, status, unassigned]

empty

set_condition: [COND, empty, field]

Returns True if field exists and its value is empty (empty string or whitespace only). Returns False if the field is absent or has a non-empty value.

Example:

tasks:
- set_condition: [NO_DESC, empty, description]
- field_set: [NO_DESC, status, incomplete]

not_empty

set_condition: [COND, not_empty, field]

Returns True if field exists and its value is not empty (not empty string, not whitespace only). Returns False if the field is absent or its value is empty.

Example:

tasks:
- set_condition: [HAS_NAME, not_empty, name]
- field_set: [HAS_NAME, status, active]

is_true

set_condition: [COND, is_true, field]

Returns True if field exists and its value is in the boolean true list: on, On, ON, yes, Yes, YES, True, true, TRUE, 1 (string), 1 (int), True (bool). Returns False if the field is absent or its value is not in the true list.

Example:

tasks:
- set_condition: [IS_ON, is_true, enabled]
- field_set: [IS_ON, status, active]

is_false

set_condition: [COND, is_false, field]

Returns True if field exists and its value is not in the boolean true list (i.e. falsy: false, no, 0, empty string, etc.). Returns False if the field is absent.

Example:

tasks:
- set_condition: [IS_OFF, is_false, enabled]
- field_set: [IS_OFF, status, inactive]

is_int

set_condition: [COND, is_int, field]

Returns True if field exists and its value can be parsed as an integer. Returns False if the field is absent or the value is not a valid integer (e.g. floats, strings).

Example:

tasks:
- set_condition: [VALID, is_int, count]
- field_set: [!VALID, status, error]

is_float

set_condition: [COND, is_float, field]

Returns True if field exists and its value can be parsed as a float (integers are also valid floats). Returns False if the field is absent or the value is not numeric.

Example:

tasks:
- set_condition: [VALID, is_float, price]
- field_set: [!VALID, status, error]

is_boolean

set_condition: [COND, is_boolean, field]

Returns True if field exists and its value is a recognized boolean string or value: true, True, TRUE, false, False, FALSE, yes, Yes, YES, no, No, NO, on, On, ON, 1, 0, 1 (int), 0 (int), True (bool), False (bool). Returns False otherwise.

Example:

tasks:
- set_condition: [VALID, is_boolean, enabled]
- field_set: [!VALID, status, error]

is_date

set_condition: [COND, is_date, field]

Returns True if field exists and its value matches the format YYYY-MM-DD. Returns False if the field is absent or the format does not match.

Example:

tasks:
- set_condition: [VALID, is_date, start_date]
- field_set: [!VALID, status, error]

is_time

set_condition: [COND, is_time, field]

Returns True if field exists and its value matches the format HH:MM:SS. Returns False if the field is absent or the format does not match.

Example:

tasks:
- set_condition: [VALID, is_time, start_time]
- field_set: [!VALID, status, error]

is_datetime

set_condition: [COND, is_datetime, field]

Returns True if field exists and its value matches the format YYYY-MM-DD HH:MM:SS. Returns False if the field is absent or the format does not match.

Example:

tasks:
- set_condition: [VALID, is_datetime, last_sync]
- field_set: [!VALID, status, error]

is_ip4

set_condition: [COND, is_ip4, field]

Returns True if field exists and its value is a valid IPv4 address (A.B.C.D, no mask). Returns False if the field is absent, contains a subnet notation, or is otherwise invalid.

Example:

tasks:
- set_condition: [VALID, is_ip4, ip_address]
- field_set: [!VALID, status, error]

is_subnet

set_condition: [COND, is_subnet, field]

Returns True if field exists and its value is a valid IPv4 subnet in CIDR notation (A.B.C.D/N, mask 0–32). Returns False if the field is absent, is a bare IP address, or has an invalid mask.

Example:

tasks:
- set_condition: [VALID, is_subnet, network]
- field_set: [!VALID, status, error]