reference

Logic Reference

Reference of Noop Logic Operators

add

Add a list of numbers together. Strings will be converted to numbers, null is treated as 0.

Return Value

(number)

Parameters

operand (number, string, null)

Examples

Example 1

add:
  - 1
  - 1

Returns

2

Example 2

add:
  - 1
  - '1'

Returns

2

Example 3

add:
  - 1
  - add:
      - 2
      - 3

Returns

6

and

Determines whether all arguments evaluate truthy.

Return Value

(boolean)

Parameters

condition (number, string, null, array, object, boolean)

Examples

Example 1

and:
  - and:
      - true
      - true
  - and:
      - 1
      - 1

Returns

true

Example 2

and:
  - and:
      - '1'
      - 1
  - and:
      - true
      - true

Returns

true

concat

Concatenate array or values into single array

Parameters

(number, string, null, array, object, boolean)

Examples

Example 1

concat:
  - - 1
    - 2
  - - 3
    - 4
  - - 5
    - 6

Returns

[
  1,
  2,
  3,
  4,
  5,
  6
]

Example 2

concat:
  - - 1
    - 2
  - - - 3
      - 4
    - 5
    - 6
  - - 7
    - 8

Returns

[
  1,
  2,
  [
    3,
    4
  ],
  5,
  6,
  7,
  8
]

divide

Divide two numbers, Logic will attempt to convert strings to numbers, null is treated as 0

Return Value

(number)

Parameters

dividend (number, string, null)

divisor (number, string)

Examples

endswith

Determines whether a string ends with the characters of this search string. Number arguments are converted to strings.

Return Value

(boolean)

Parameters

string (number, string)

searchString (number, string)

Examples

Example 1

endswith:
  - Hello, friend
  - friend

Returns

true

Example 2

endswith:
  - 42
  - 2

Returns

true

Example 3

endswith:
  - Hello, friend
  - Joe

Returns

false

equals

Determines if all arguments are the same, returns true of false as appropriate.

Return Value

(boolean)

Parameters

(number, string, null, array, object, boolean)

Examples

Example 1

equals:
  - 1
  - 1

Returns

true

Example 2

equals:
  - true
  - false

Returns

false

Example 3

equals:
  - 7
  - 7
  - 7

Returns

true

filter

Filter an array of items by a condition. When the condition evaluates true for the given item, the item is added to the returned array.

Return Value

(array)

Parameters

sourceArray (array)

condition (object)

itemName (string, null)

indexName (string, null)

Examples

Example 1

filter:
  - - 2
    - 3
    - 4
  - greater:
      - var: _item
      - 2

Returns

[
  3,
  4
]

Example 2

filter:
  - - 2
    - 3
    - 4
  - equals:
      - var: _index
      - 1

Returns

[
  3
]

Example 3

filter:
  - - banana
    - apple
    - mango
  - endswith:
      - var: fruit
      - pple
  - fruit

Returns

[
  "apple"
]

Example 4

filter:
  - - grapple
    - tackle
    - scrapple
  - and:
      - endswith:
          - var: _item
          - pple
      - greaterequals:
          - var: position
          - 1
  - null
  - position

Returns

[
  "scrapple"
]

find

Find an item in an array using a match condition expression. The first item in the array that matches the condition will be returned.

Return Value

(number, string, null, array, object, boolean)

Parameters

sourceArray (array)

condition (object)

itemName (string, null)

indexName (string, null)

Examples

Example 1

find:
  - - 2
    - 3
    - 4
  - greater:
      - var: _item
      - 2

Returns

3

Example 2

find:
  - - 2
    - 3
    - 4
  - equals:
      - var: _index
      - 1

Returns

3

Example 3

find:
  - - banana
    - apple
    - mango
  - endswith:
      - var: fruit
      - pple
  - fruit

Returns

"apple"

Example 4

find:
  - - grapple
    - tackle
    - scrapple
  - and:
      - endswith:
          - var: _item
          - pple
      - greaterequals:
          - var: position
          - 1
  - null
  - position

Returns

"scrapple"

flat

Flattens nested arrays to the specied depth.

Return Value

(array)

Parameters

sourceArrays (array)

depth (number, string)

Examples

Example 1

flat:
  - - - - 1
      - 2
    - 2

Returns

[
  [
    1
  ],
  2,
  2
]

Example 2

flat:
  - - - - 1
      - 2

Returns

[
  [
    1
  ],
  2
]

glob

Determines whether a source path matches for any of the provided glob patterns. Returns boolean.

Return Value

(boolean)

Parameters

sourcePath (number, string)

globPattern (string, number)

Examples

Example 1

glob:
  - /santa/lives/up/north
  - '**/up/north'

Returns

true

Example 2

glob:
  - /santa/lives/up/north
  - /santa/**
  - '**/down/south'

Returns

true

Example 3

glob:
  - /santa/lives/up/north
  - '**/down/south'

Returns

false

greater

Determines if valueA is greater than valueB.

Return Value

(boolean)

Parameters

valueA (number, string, null)

valueB (number, string, null)

Examples

Example 1

greater:
  - 2
  - 1

Returns

true

Example 2

greater:
  - 1
  - 1

Returns

false

greaterequals

Determines if valueA is greater than or equal to valueB.

Return Value

(boolean)

Parameters

valueA (number, string, null)

valueB (number, string, null)

Examples

Example 1

greaterequals:
  - 2
  - 1

Returns

true

Example 2

greaterequals:
  - 1
  - 1

Returns

true

Example 3

greaterequals:
  - 0
  - 1

Returns

false

has

Determines if an object includes a specific key. Returns a boolean.

Return Value

(boolean)

Parameters

object (array, object)

key (number, string)

Examples

Example 1

has:
  - first_name: Joe
  - first_name

Returns

true

Example 2

has:
  - first_name: Joe
  - last_name

Returns

false

if

Creates branching logic. When the first argument evaluates truthy the second argument, ifResult is returned, otherwise, the third, elseResult is returned.

Return Value

(number, string, object, array, boolean, null) When no if or else results are defined then default return is a boolean, otherwise it is the return value of the ifResult or elseResult expressions.

Parameters

condition (number, string, object, array, boolean, null)

ifResult (number, string, object, array, boolean, null)

elseResult (number, string, object, array, boolean, null)

Examples

Example 1

if:
  - equals:
      - 1
      - 1
  - foo
  - bar

Returns

"foo"

ifnot

Creates branching logic. When the first argument evaluates falsy the second argument, ifResult is returned, otherwise, the third, elseResult is returned.

Return Value

(number, string, object, array, boolean, null) When no if or else results are defined then default return is a boolean, otherwise it is the return value of the ifResult or elseResult expressions.

Parameters

condition (number, string, object, array, boolean, null)

ifResult (number, string, object, array, boolean, null)

elseResult (number, string, object, array, boolean, null)

Examples

includes

determines whether an array or string contains a specified search element, returns a boolean.

Return Value

(boolean)

Parameters

source (array, string)

searchElement (number, string, null, array, object, boolean)

Examples

Example 1

includes:
  - - 1
    - 2
    - 3
  - 2

Returns

true

Example 2

includes:
  - - 1
    - 2
    - 3
  - 0

Returns

false

join

Creates and returns a string by concatenating all of the elements in the items array, separated by specified separator string or empty string. If the array has only one item, then that item will be returned without using the separator.

Return Value

(string)

Parameters

items (array)

separator (number, string, object)

Examples

Example 1

join:
  - - Hamburger
    - Fries
    - Soda
  - ' & '

Returns

"Hamburger & Fries & Soda"

Example 2

join:
  - - This
    - Or
    - That

Returns

"ThisOrThat"

length

Returns the number of items or character in the specified array or string respectively.

Return Value

(number)

Parameters

array (array, string)

Examples

Example 1

length:
  - 0
  - 1
  - 2

Returns

3

Example 2

length:
  - foo
  - bar
  - baz

Returns

3

less

Determines if valueA is less than valueB.

Return Value

(boolean)

Parameters

valueA (number, string, null)

valueB (number, string, null)

Examples

Example 1

less:
  - 1
  - 1

Returns

false

Example 2

less:
  - 0
  - 1

Returns

true

lessequals

Determines if valueA is less than or equal to valueB.

Parameters

valueA (number, string, null)

valueB (number, string, null)

Examples

Example 1

lessequals:
  - 2
  - 1

Returns

false

Example 2

lessequals:
  - 1
  - 1

Returns

true

Example 3

lessequals:
  - 0
  - 1

Returns

true

map

Creates a new array populated with the results of calling a provided Logic expression on every element in the provided array.

Return Value

(array)

Parameters

sourceArray (array)

logicExpression (object)

itemName (string, null)

indexName (string, null)

Examples

Example 1

map:
  - - 1
    - 2
    - 3
  - add:
      - var: _item
      - 2

Returns

[
  3,
  4,
  5
]

Example 2

map:
  - - 1
    - 2
    - 3
  - if:
      - modulo:
          - var: _index
          - 2

Returns

[
  false,
  true,
  false
]

Example 3

map:
  - - banana
    - apple
    - mango
  - var: <fruit>s
  - fruit

Returns

[
  "bananas",
  "apples",
  "mangos"
]

Example 4

map:
  - - banana
    - apple
    - mango
  - if:
      - equals:
          - var: position
          - 1
      - yummy
      - nasty
  - null
  - position

Returns

[
  "nasty",
  "yummy",
  "nasty"
]

max

Returns the largest of given values, strings are converted to numbers. Returns a number.

Return Value

(number)

Parameters

value (number, string, null)

Examples

Example 1

max:
  - 1
  - 2
  - 3

Returns

3

Example 2

max:
  - 1
  - 2
  - '3'

Returns

3

Example 3

max:
  - 100
  - 42
  - '3'

Returns

100

min

Returns the smallest of given values, strings are converted to numbers. Returns a number.

Return Value

(number)

Parameters

value (number, string, null)

Examples

Example 1

min:
  - 1
  - 2
  - 3

Returns

1

Example 2

min:
  - 1
  - 2
  - '3'

Returns

1

Example 3

min:
  - 100
  - 42
  - '3'

Returns

3

modulo

Returns the remainder after performing a division.

Parameters

dividend (number, string, null)

divisor (number, string)

Examples

Example 1

modulo:
  - 13
  - 5

Returns

3

Example 2

modulo:
  - 1
  - -2

Returns

1

Example 3

modulo:
  - 1
  - 2

Returns

1

Example 4

modulo:
  - -13
  - 5

Returns

-3

Example 5

modulo:
  - -4
  - 2

Returns

0

Example 6

modulo:
  - 5.5
  - 2

Returns

1.5

multiply

Produces the product of the operands.

Return Value

(number)

Parameters

operand (number, string, null)

Examples

Example 1

multiply:
  - 1
  - 2
  - 3

Returns

6

Example 2

multiply:
  - 50
  - 50
  - 50

Returns

125000

Example 3

multiply:
  - 21
  - 2

Returns

42

netmask

Determines if an IP address is within one of the provided CIDR ranges.

Return Value

(boolean)

Parameters

ipAddress (string)

cidr (string)

Examples

Example 1

netmask:
  - 17.17.17.17
  - 17.17.0.0/16

Returns

true

Example 2

netmask:
  - 17.17.17.17
  - 17.17.17.0/24

Returns

true

Example 3

netmask:
  - 17.17.17.17
  - 17.17.17.0/32

Returns

false

Example 4

netmask:
  - 17.17.17.17
  - 17.17.17.0/24
  - 2.0.0.0/16

Returns

true

notequals

Determines if all arguments are not the same, returns true of false as appropriate.

Return Value

(boolean)

Parameters

(number, string, null, array, object, boolean)

Examples

Example 1

notequals:
  - 1
  - 1

Returns

false

Example 2

notequals:
  - true
  - false

Returns

true

Example 3

notequals:
  - 7
  - 7
  - 42

Returns

false

or

Determines whether any of the conditions evaluate truthy.

Return Value

(boolean)

Parameters

condition (number, string, null, array, object, boolean)

Examples

Example 1

or:
  - or:
      - false
  - or:
      - 1
      - 0

Returns

true

Example 2

or:
  - or:
      - 0
  - or:
      - false
      - null

Returns

false

querystring

Produces a list of list pairs for each entry in the provided query string.

Return Value

(array)

Parameters

querystring (string)

Examples

Example 1

querystring:
  - ?santa=claus&bat=man

Returns

[
  [
    "santa",
    "claus"
  ],
  [
    "bat",
    "man"
  ]
]

reduce

Executes a “reducer” Logic expression on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value. An optional start value is passed as the initial execution of the reducer.

Return Value

(number, string, object, array, boolean, null)

Parameters

sourceArray (array)

reducerExpression (object)

startValue (number, string, object, array, boolean, null)

Examples

Example 1

reduce:
  - - 1
    - 2
    - 3
  - add:
      - var: _previous
      - var: _current
  - 10

Returns

16

Example 2

reduce:
  - - 1
    - 2
    - 3
    - 4
  - subtract:
      - var: _previous
      - var: _current
  - 10

Returns

0

Determines whether a substring is present within a log entry’s search string, returns a boolean.

Return Value

(boolean)

Parameters

searchElement (number, string, boolean, null)

Examples

Example 1

search: foobar

Returns

false

Example 2

search: 123

Returns

false

Example 3

search: true

Returns

false

slice

Returns a portion of an array selected from start to end (end not included) where start and end represent the index of items in that array.

Return Value

(array)

Parameters

sourceArray (number, string, array)

rangeStart (number, string)

rangeEnd (number, string)

Examples

Example 1

slice:
  - - 1
    - 2
    - 3
  - 0
  - 1

Returns

[
  1
]

Example 2

slice:
  - - 1
    - 2
    - 3
  - 0

Returns

[
  1,
  2,
  3
]

sort

Returns a new sorted array by calling a provided Logic comparison expression on the provided array.

Parameters

sourceArray (array)

logicExpression (object)

prefixName (string)

Examples

Example 1

sort:
  - - 3
    - 2
    - 5
    - 1
    - 4

Returns

[
  1,
  2,
  3,
  4,
  5
]

Example 2

sort:
  - - 3
    - 2
    - 5
    - 1
    - 4
  - if:
      - greater:
          - var: _item_a
          - var: _item_b
      - -1
      - 1

Returns

[
  5,
  4,
  3,
  2,
  1
]

Example 3

sort:
  - - mango
    - apple
    - pear
    - banana

Returns

[
  "apple",
  "banana",
  "mango",
  "pear"
]

Example 4

sort:
  - - mango
    - apple
    - pear
    - banana
  - if:
      - greater:
          - var: fruit_a
          - var: fruit_b
      - -1
      - 1
  - fruit

Returns

[
  "pear",
  "mango",
  "banana",
  "apple"
]

startswith

Determines whether a string starts with the characters of this search string. Number arguments are converted to strings.

Return Value

(boolean)

Parameters

string (number, string)

searchString (number, string)

Examples

Example 1

startswith:
  - Hello, friend
  - Hello

Returns

true

Example 2

startswith:
  - 42
  - 4

Returns

true

Example 3

startswith:
  - Hello, friend
  - friend

Returns

false

substring

Returns a portion of a string selected from start to end (end not included) where start and end represent the index of character in that string, starting from 0.

Return Value

(string)

Parameters

sourceString (number, string)

rangeStart (number, string)

rangeEnd (number, string)

(number, string)

Examples

subtract

Subtracts a list of numbers in sequence from first to last. Strings will be converted to numbers, null is treated as 0.

Return Value

(number)

Parameters

(number, string, null)

Examples

Example 1

subtract:
  - 5
  - 3
  - 2

Returns

0

Example 2

subtract:
  - subtract:
      - 10
      - 12
  - 3
  - 2

Returns

-7

undefined

undefined

Parameters

(string)

Examples

unique

Produces a list of items with all duplicate values reduced to a single instance.

Return Value

(array)

Parameters

item (number, string, object, array, boolean, null)

Examples

Example 1

unique:
  - banana
  - banana
  - pear

Returns

[
  "banana",
  "pear"
]

Example 2

unique:
  - banana
  - pear

Returns

[
  "banana",
  "pear"
]

Example 3

unique:
  - banana
  - banana
  - banana
  - mango
  - mango

Returns

[
  "banana",
  "mango"
]

useragent

Parses a user agent string constructing an object with user agent data separated into individual object properties

Return Value

useragent: (object) Object with user agent data organized by individual property

{
  "ua": {
    "type": "string"
  },
  "browser": {
    "name": {
      "type": "string"
    },
    "version": {
      "type": "string"
    }
  },
  "engine": {
    "name": {
      "type": "string"
    },
    "version": {
      "type": "string"
    }
  },
  "os": {
    "name": {
      "type": "string"
    },
    "version": {
      "type": "string"
    }
  },
  "device": {
    "model": {
      "type": "string"
    },
    "type": {
      "type": "string"
    },
    "vendor": {
      "type": "string"
    }
  },
  "cpu": {
    "architecture": {
      "type": "string"
    }
  }
}

Parameters

userAgentString (string)

Examples

Example 1

useragent:
  - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko)
    Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2

Returns

{
  "ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2",
  "browser": {
    "name": "Chromium",
    "version": "15.0.874.106",
    "major": "15"
  },
  "engine": {
    "name": "WebKit",
    "version": "535.2"
  },
  "os": {
    "name": "Ubuntu",
    "version": "11.10"
  },
  "device": {},
  "cpu": {
    "architecture": "amd64"
  }
}

var

Retrieves the value of a given variable path, sub-indexes separated with ”.“. Optionally provide a data object for which to access the variable path from.

Parameters

path (number, string, boolean, null)

data (number, string, object, array, boolean, null)

Examples

Example 1

var: _item

Returns

"doorknob"

Example 2

var: $request.content-type

Returns

"application/html"

Example 3

var: fancy.thing

Returns

"snow globe"