FormWork FormWork

Operators Reference

Complete reference of all operators available for conditional logic and validation.

This reference lists all operators available in FormWork for conditional logic and validation rules.

Comparison Operators

equals (eq)

Checks if values are exactly equal.

"status" eq "active"
"count" eq 5

Supported Types: All field types

Notes:

  • Case-sensitive for strings
  • Type-aware (5 ≠ “5”)

not equals (neq)

Checks if values are not equal.

"status" neq "deleted"
"score" neq 0

Supported Types: All field types

greater than (gt)

Checks if value is greater than comparison.

"age" gt 18
"price" gt 100.00
"date" gt "2024-01-01"

Supported Types: Number, Date, DateTime

greater than or equal (gte)

Checks if value is greater than or equal to comparison.

"quantity" gte 1
"score" gte 80

Supported Types: Number, Date, DateTime

less than (lt)

Checks if value is less than comparison.

"quantity" lt 100
"end_date" lt "2024-12-31"

Supported Types: Number, Date, DateTime

less than or equal (lte)

Checks if value is less than or equal to comparison.

"discount" lte 50
"priority" lte 3

Supported Types: Number, Date, DateTime

Text Operators

contains

Checks if text contains a substring.

"email" contains "@company.com"
"description" contains "urgent"

Supported Types: Text, Textarea, Email, URL

Notes: Case-sensitive

not contains (not_contains)

Checks if text does not contain a substring.

"email" not_contains "test"
"name" not_contains "bot"

Supported Types: Text, Textarea, Email, URL

starts with (starts_with)

Checks if text begins with a prefix.

"phone" starts_with "+1"
"code" starts_with "PRO-"

Supported Types: Text, Textarea

ends with (ends_with)

Checks if text ends with a suffix.

"email" ends_with ".edu"
"file" ends_with ".pdf"

Supported Types: Text, Textarea, Email

matches pattern (matches_pattern)

Checks if text matches a regular expression.

"zip" matches_pattern "^\d{5}$"
"phone" matches_pattern "^\+?[\d\s-]+$"
"email" matches_pattern "^[a-z]+@company\.com$"

Supported Types: Text, Textarea, Email, URL, Phone

Regex Syntax: Uses standard regex. Special characters like {, }, [, ] need escaping with \.

Length Operators

length equals (length_eq)

Checks if value length equals a number.

"zip" length_eq 5
"code" length_eq 6

Supported Types: Text, Textarea, Array (Multiselect, Files)

length not equals (length_neq)

Checks if value length does not equal a number.

"pin" length_neq 4

length greater than (length_gt)

Checks if value length is greater than a number.

"message" length_gt 10
"selections" length_gt 0

length greater than or equal (length_gte)

"password" length_gte 8

length less than (length_lt)

Checks if value length is less than a number.

"title" length_lt 100
"tags" length_lt 5

length less than or equal (length_lte)

"name" length_lte 50
"files" length_lte 3

Boolean Operators

is true (is_true)

Checks if boolean value is true.

"agree_terms" is_true
"newsletter_opt_in" is_true

Supported Types: Toggle

is false (is_false)

Checks if boolean value is false.

"do_not_contact" is_false

Supported Types: Toggle

Empty Operators

is empty (is_empty)

Checks if field has no value.

"middle_name" is_empty
"optional_notes" is_empty

Supported Types: All field types

Notes:

  • Empty string counts as empty
  • 0 is NOT empty for numbers
  • Empty array counts as empty

is not empty (is_not_empty)

Checks if field has a value.

"email" is_not_empty
"required_file" is_not_empty

Supported Types: All field types

Type Validation Operators

is email (is_email)

Validates email format.

"contact" is_email

Checks for: Contains @, has domain part

is URL (is_url)

Validates URL format.

"website" is_url

Checks for: Starts with http:// or https://

is number (is_number)

Checks if value is a valid number.

"quantity" is_number

Includes: Integers and decimals

is integer (is_integer)

Checks if value is a whole number.

"count" is_integer

Excludes: Decimals

is float (is_float)

Checks if value is a decimal number.

"price" is_float

is alpha (is_alpha)

Checks if value contains only letters.

"first_name" is_alpha

Includes: a-z, A-Z

Excludes: Numbers, spaces, special characters

is alphanumeric (is_alphanum)

Checks if value contains only letters and numbers.

"username" is_alphanum

Includes: a-z, A-Z, 0-9

Excludes: Spaces, special characters

Combining Operators

Logic Types

TypeDescriptionBehavior
allAND logicAll conditions must be true
anyOR logicAt least one condition must be true

Nested Groups

Combine groups for complex expressions:

{
  "type": "all",
  "groups": [
    {
      "type": "any",
      "rules": [
        { "field": "status", "operator": "eq", "value": "premium" },
        { "field": "orders", "operator": "gt", "value": 10 }
      ]
    },
    {
      "type": "all",
      "rules": [
        { "field": "country", "operator": "eq", "value": "US" }
      ]
    }
  ]
}

This means: (status = premium OR orders > 10) AND country = US

Operator Quick Reference

OperatorSymbolExample
equalseqstatus eq "active"
not equalsneqtype neq "deleted"
greater thangtage gt 18
greater or equalgtescore gte 80
less thanltqty lt 100
less or equallteprice lte 50
containscontainsemail contains "@"
not containsnot_containsname not_contains "test"
starts withstarts_withcode starts_with "A"
ends withends_withfile ends_with ".pdf"
matches patternmatches_patternzip matches_pattern "^\d{5}$"
length equalslength_eqpin length_eq 4
length not equalslength_neqcode length_neq 0
length greaterlength_gtmsg length_gt 10
length greater or eqlength_gtepwd length_gte 8
length lesslength_lttitle length_lt 100
length less or eqlength_ltetags length_lte 5
is trueis_trueagreed is_true
is falseis_falseoptout is_false
is emptyis_emptynotes is_empty
is not emptyis_not_emptyemail is_not_empty
is emailis_emailcontact is_email
is urlis_urlsite is_url
is numberis_numberqty is_number
is integeris_integercount is_integer
is floatis_floatprice is_float
is alphais_alphaname is_alpha
is alphanumis_alphanumuser is_alphanum