Skip to main content
This is the full reference for everything you can use inside Lark security rule expressions. If you’re new to rules, start with the security rules overview first.

Variables

These variables are available in every rule expression.
data and newData are scoped to the current path where the rule is defined. Use root when you need to look up data elsewhere in your database.

Snapshot methods

The data, newData, and root variables are all snapshots. You can call these methods on any snapshot.

Examples

String methods

These methods are available on any string value in a rule expression, including auth.uid, $wildcard captures, and string values returned by val().

Examples

Operators

Standard operators work inside rule expressions.

Comparison

== is treated as === and != is treated as !== in rules. Both are strict comparisons; there is no loose equality.

Logical

Arithmetic

Ternary

Use the + operator to build dynamic paths for child() lookups: root.child('users/' + auth.uid + '/role').val() === 'admin'.

Query-based rules

You can restrict what queries clients are allowed to run by referencing query. expressions in your rules. This lets you enforce that clients include certain filters or limits.

Query variables

Examples

Restrict access to a collection so clients can only read their own items:
A query that includes the required parameters succeeds:
A query without the parameters fails:
Limit how much data a client can download:

What’s next

Rules examples

See these building blocks in action with real-world patterns.

Security rules

Go back to the overview to understand how rules are structured and evaluated.