Values·续
Accessing an out-of-bounds array index produces a missing value.
You can only use [*] multiple times in the same expression if applied to the same array. Also, you can only use [*] in the first argument of a function call.
The Rules language operators do not directly support arrays or the [*] operator — however, they support indexed array elements like array_value[0]. For example, you cannot use [*] with the == operator outside the context of an enclosing function call:
http.request.headers.names[*] == "Content-Type"— Invalid expressionany(http.request.headers.names[*] == "Content-Type")— Valid expression
Maps
A map, also called associative array, is a data structure that stores a collection of key-value pairs, where the key must be a String and the value can be of any type (for example, a String or an array of values). All values in a map must have the same type.
The Cloudflare Rules language includes several fields of Map data type. The type notation for map fields, for example Map<Array<String>>, indicates the data type of the values associated with keys (an Array of String elements). This means that when you access the value of key "foo" you will get either an array of String elements or a missing value.
To access a value in a map, enter the key between square brackets ([]):
<MAP_FIELD>[<KEY>]
For maps where the values have an Array type, you cannot directly use operators with the obtained (array) value, since these operators do not support arrays directly. To use an operator on an item of the array, use the special notation [*] when specifying an expression. This special index notation will unpack the array, call the enclosing function for all its elements individually, and return a new array containing all the individual return values.
Examples
The following example is based on the http.request.headers field with a data type of Map<Array<String>>, where array elements are of String data type.
If an incoming HTTP request included a single Accept: application/json HTTP header, the following expressions would evaluate to the indicated values:
http.request.headers["accept"] # ==> ["application/json"]
http.request.headers["accept"][0] # ==> "application/json"
any(http.request.headers["accept"][*] == "application/json") # ==> true
any(http.request.headers["accept"][*] == "text/plain") # ==> false
The following example is based on the http.request.uri.args field with a data type of Map<Array<String>>, where array elements are of String data type.
If an HTTP request included three filter URI arguments waf, botm, and cdn, the following expressions would evaluate to the indicated values:
# Example request URL:
# https://example.com/?filter=waf&filter=botm&filter=cdn
http.request.uri.args["filter"] # ==> ["waf", "botm", "cdn"]
len(http.request.uri.args["filter"][1]) # ==> 4
# Check if the length of all 'filter' values is always 3 or 4
all(len(http.request.uri.args["filter"][*])[*] in {3 4}) # ==> true
# Check if the length of 'filter' values (if any) is never 3 or 4
all(not len(http.request.uri.args["filter"][*])[*] in {3 4}) # ==> false
# Check if the http.request.uri.args map contains a "filter" key
len(http.request.uri.args["filter"]) >= 0 # ==> true
# Check if the http.request.uri.args map does not contain an "order" key
not len(http.request.uri.args["order"]) >= 0 # ==> true
For more information on any(), all(), len(), and other available functions, refer to Functions.
Notes
It is not possible to define your own maps. You can only use maps returned by fields.
Accessing a key that does not exist produces a missing value.
Missing values
An absent map key or out-of-bounds array index produces a missing value (nil). Nil is not a literal you can enter in an expression.
Comparisons
These results apply to HTTP rules when both values have the same type. The following table shows the result of each comparison:
| Operand values | eq |
ne |
lt |
le |
gt |
ge |
|---|---|---|---|---|---|---|
| Both nil | true |
false |
false |
true |
false |
true |
| Exactly one nil | false |
true |
false |
false |
false |
false |
The one-nil results also apply when the other operand is a literal.
Caution
An equality rule might match nearly every request if both values are usually nil. The following expressions return different results when both query parameters are missing:
# Returns true
http.request.uri.args["first"][0] eq http.request.uri.args["second"][0]
# Returns false because the empty string is different from nil
coalesce(http.request.uri.args["first"][0], "") eq http.request.uri.args["second"][0]
Functions
Functions usually return nil when an argument is nil. The exact behavior varies by function. Use coalesce() to provide a fallback value.
Lists
Lists allow you to create a group of items and refer to them collectively, by name, in your expressions. Each list type supports items of a specific data type. All items in a list must have the same data type. For details on the available list types, refer to Lists.
To refer to a list in a rule expression, use $<list_name> and specify the in operator. Only one value in the list has to match the left-hand side of the expression (before the in operator) for the simple expression to evaluate to true. If there is no match, the expression will evaluate to false.
The following example expression filters requests from IP addresses that are in an IP list named office_network:
(ip.src in $office_network)
List names can only include lowercase letters, numbers, and the underscore (_) character. For guidance on creating and managing lists, refer to Lists.
Inline lists
Inline lists allow you to directly include a list of values in a simple expression that uses the in operator.
Elements in an inline list can be strings, integers, or IP addresses/ranges. All elements of an inline list must have the same data type and they must be literal values. To specify inline list elements, enter them individually, separating elements with a space. Inline lists can contain duplicate values.
Additionally, for some data types you can use ranges as elements:
- For integer values, enter ranges in the form
<start_value>..<end_value>. An inline list can contain both integer ranges and integer values. - For IP addresses, you can enter:
- Explicit IP ranges in the form
<start_address>..<end_address>(for example,198.51.100.3..198.51.100.7). - CIDR ranges (for example,
192.0.2.0/24or2001:0db8::/32).
An inline list can contain explicit IP ranges, CIDR ranges, and individual IP addresses.
Examplessql
http.host in {"example.com" "example.net"}
ip.src in {198.51.100.1 198.51.100.3..198.51.100.7 192.0.2.0/24 2001:0db8::/32}
tcp.dstport in {8000..8009 8080..8089}
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ruleset-engine/rules-language/values/#page","headline":"Values","description":"Learn about values in Cloudflare's Rules language, including string, boolean, array, and map types, and how to use them in rule expressions.","url":"https://developers.cloudflare.com/ruleset-engine/rules-language/values/","inLanguage":"en","image":"https://developers.cloudflare.com/ruleset-engine/rules-language/values/og.png?v=9b488c6812d4ee15","dateModified":"2026-10-01","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Manage rulesets and rules programmatically with the Rulesets API. title: Rulesets API image: https://developers.cloudflare.com/ruleset-engine/rulesets-api/og.png?v=2506693cfeada851
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/ruleset-engine/llms.txt
Use this file to discover all available pages before exploring further.
Docs