Skip to main content

Expresso Operators

Generated automatically from operator metadata

Total Operators: 145


array

OperatorDescription
mapTransform each element of an array using a rule
reduceReduce array to single value using a rule
filterFilter array elements using a rule
allCheck if all elements match a rule
noneCheck if no elements match a rule
someCheck if any element matches a rule
mergeConcatenate multiple arrays together
flattenFlatten nested arrays into a single array
sortSort array elements in ascending order
sort_bySort array of objects by property
findFind first element matching a rule
find_indexFind index of first element matching a rule
group_byGroup array of objects by property
intersectionFind common elements across multiple arrays
differenceElements in first array not in second array
unionCombine all unique elements from multiple arrays

auth

OperatorDescription
auth_is_authenticatedReturns true if the user has a valid authentication context
auth_has_roleReturns true if the user has the specified role
auth_has_any_roleReturns true if the user has any of the specified roles
auth_has_all_rolesReturns true if the user has all of the specified roles
auth_has_permissionReturns true if the user has the specified permission
auth_has_any_permissionReturns true if the user has any of the specified permissions
auth_has_all_permissionsReturns true if the user has all of the specified permissions
auth_claim_equalsReturns true if the specified claim equals the expected value
auth_claim_includesReturns true if the claim (string or array) includes the specified token
auth_is_ownerReturns true if the authenticated user ID matches the value at the specified path
auth_is_tenant_memberReturns true if the user belongs to the tenant specified at the path
auth_has_scopeReturns true if the user has the specified OAuth scope
auth_attribute_matchEvaluates an expresso rule against the auth context for arbitrary ABAC policies. Auth context fields (sub, roles, permissions, claims, tenantId, orgId, scope) are available as top-level variables.
auth_denyUnconditionally denies access, optionally with a reason
auth_allowUnconditionally allows access

comparisons

OperatorDescription
==Loose equality comparison using ==
===Strict equality comparison using ===
!=Loose inequality comparison using !=
!==Strict inequality comparison using !==

crypto

OperatorDescription
hashCompute hash of a string using specified algorithm (SHA-1, SHA-256, SHA-384, SHA-512)
hmacCompute HMAC signature of a message using specified algorithm and key
uuid_generateGenerate a random UUID v4
uuid_validateValidate if a string is a valid UUID v4 format
base64_encodeEncode a string to Base64
base64_decodeDecode a Base64 string

data-access

OperatorDescription
varAccess nested data by path, parent scopes with ../, and iteration metadata
missingCheck if any fields are missing (null or undefined)
missing_someCheck if at least N fields are missing

date

OperatorDescription
to_datetimeConvert timestamp or date string to ISO datetime
nowCurrent timestamp
date_parseParse date string to ISO format
date_formatFormat date string using custom format. Supports: %Y (year), %m (month), %d (day), %H (hour), %M (minute), %S (second)
date_addAdd time to a date. Supported units: years, months, days, hours, minutes, seconds
date_diffCalculate difference between two dates in specified unit
date_betweenCheck if date is between start and end dates (inclusive)
is_weekdayCheck if date is a weekday (Monday-Friday)
is_weekendCheck if date is a weekend (Saturday-Sunday)

logic

OperatorDescription
orLogical OR with short-circuit evaluation
andLogical AND with short-circuit evaluation
!Logical NOT operator
!!Double logical NOT (converts to boolean)
ifConditional operator - supports if/then/elseif/then/.../else pattern. Returns the first then value whose condition is truthy, or final else value.
switchSwitch/case operator with fall-through default
ternaryTernary operator (condition ? then : else)
coalesceReturns first non-null/undefined value
defaultReturns value or default if null/undefined
tryEnhanced try-catch with type and pattern matching. Supports simple fallback or multiple catch handlers with type matching, pattern matching, or both.
throwThrow a custom error with optional code, severity, and type. Supports multiple syntax forms: string, [message], [message, code], [message, code, severity], or {message, code, severity, type}
xorExclusive OR - returns true if exactly one operand is truthy
impliesLogical implication - returns true if p is false or q is true (equivalent to !p || q)
assertAssert operator - throws an error if condition is falsy, otherwise returns the condition value. Useful for precondition validation.

misc

OperatorDescription
logConsole log
!existsCheck if value is null or undefined

numeric

OperatorDescription
greater-thanChecks if first number is greater than second
>Checks if first number is greater than second
greater-equalChecks if first number is greater than or equal to second
>=Checks if first number is greater than or equal to second
less-thanChecks if first number is less than second
<Checks if first number is less than second
less-equalChecks if first number is less than or equal to second
<=Checks if first number is less than or equal to second
betweenChecks if value is between min and max (inclusive)
minReturns the minimum value from an array
maxReturns the maximum value from an array
plusAdds multiple numbers together
+Adds multiple numbers together
minusSubtracts second number from first
-Subtracts second number from first
multiplyMultiplies multiple numbers together
*Multiplies multiple numbers together
divideDivides first number by second
/Divides first number by second
moduloReturns the remainder of division
%Returns the remainder of division
absReturns the absolute value of a number

object

OperatorDescription
keysGet object keys
valuesGet object values
entriesGet object entries
pickSelect specific keys from an object
omitRemove specific keys from an object
merge_deepDeep merge multiple objects together
getGet a value from a nested object by path with optional default
setSet a value at a nested path in an object (creates new object)
hasCheck if a nested path exists in an object
transformTransform object keys and values according to specified rules

regex

OperatorDescription
regex_matchTests if a string matches a regular expression pattern
regex_replaceReplaces all occurrences of a regex pattern with a replacement string
regex_extractExtracts all capture groups from a regex match. Returns array where index 0 is the full match, and subsequent indices are capture groups.
regex_testBoolean test for whether a string matches a regex pattern. Alias for regex_match.
regex_matchesBoolean test for whether a string matches a regex pattern. Alias for regex_match.

string

OperatorDescription
containsCheck if string or array contains value
!containsCheck if string or array does not contain value
splitSplit string by delimiter
trimRemove whitespace from both ends
to_lowerConvert to lowercase
to_upperConvert to uppercase
inCheck if substring/container includes value
catConcatenate strings
substrExtract substring
is_emptyCheck if empty
typeGet type of value

validation

OperatorDescription
uniqueCheck if value is unique in a projection (no existing record with this value)
existsCheck if a record exists in a projection with the given value
is_nullCheck if value is exactly null
is_undefinedCheck if value is exactly undefined
is_nilCheck if value is null or undefined
is_nanCheck if value is NaN (Not a Number)
is_finiteCheck if value is a finite number (not NaN or Infinity)
is_integerCheck if value is an integer
is_floatCheck if value is a float (has decimal part)
is_numberCheck if type is number (includes NaN)
is_finite_numberCheck if value is a finite number (excludes NaN and Infinity)
is_stringCheck if type is string
is_booleanCheck if type is boolean
is_arrayCheck if value is an array
is_objectCheck if value is a plain object (not null, not array)
is_emailCheck if value matches email format
is_urlCheck if value matches URL format (http or https)
is_uuidCheck if value matches UUID v4 format
min_lengthCheck if string or array has minimum length
max_lengthCheck if string or array has maximum length
rangeCheck if number is within inclusive range
in_rangeCheck if number is within inclusive range (alias for range)
min_valueCheck if value is greater than or equal to minimum
max_valueCheck if value is less than or equal to maximum
equals_lengthCheck if string or array has exact length
between_lengthCheck if string or array length is within range
requiredCheck if value is present and not empty
matchesCheck if value matches another value (for cross-field validation)

array

map

Title: Map

Category: array

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Transform each element of an array using a rule

Tags: array, transformation, basic

Examples

Double each number

Input:

{}

Rule:

{
"map": [
[
1,
2,
3
],
{
"*": [
{
"var": ""
},
2
]
}
]
}

Output:

[
2,
4,
6
]

reduce

Title: Reduce

Category: array

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Reduce array to single value using a rule

Tags: array, aggregation

Examples

Sum array

Input:

{}

Rule:

{
"reduce": [
[
1,
2,
3
],
{
"+": [
{
"var": "accumulator"
},
{
"var": "current"
}
]
},
0
]
}

Output:

6

filter

Title: Filter

Category: array

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Filter array elements using a rule

Tags: array, filtering, basic

Examples

Filter even numbers

Input:

{}

Rule:

{
"filter": [
[
1,
2,
3,
4,
5
],
{
"==": [
{
"%": [
{
"var": ""
},
2
]
},
0
]
}
]
}

Output:

[
2,
4
]

all

Title: All

Category: array

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Check if all elements match a rule

Tags: array, predicate

Examples

All numbers positive

Input:

{}

Rule:

{
"all": [
[
1,
2,
3
],
{
">": [
{
"var": ""
},
0
]
}
]
}

Output:

true

none

Title: None

Category: array

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Check if no elements match a rule

Tags: array, predicate

Examples

No negative numbers

Input:

{}

Rule:

{
"none": [
[
1,
2,
3
],
{
"<": [
{
"var": ""
},
0
]
}
]
}

Output:

true

some

Title: Some

Category: array

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Check if any element matches a rule

Tags: array, predicate

Examples

Some numbers positive

Input:

{}

Rule:

{
"some": [
[
-1,
0,
1
],
{
">": [
{
"var": ""
},
0
]
}
]
}

Output:

true

merge

Title: Merge

Category: array

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Concatenate multiple arrays together

Tags: array, concatenation, basic

Examples


flatten

Title: Flatten

Category: array

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Flatten nested arrays into a single array

Tags: array, transformation

Examples

Flatten nested array

Input:

{}

Rule:

{
"flatten": [
[
1,
[
2,
[
3,
4
]
],
5
]
]
}

Output:

[
1,
2,
3,
4,
5
]

sort

Title: Sort

Category: array

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n log n)

Sort array elements in ascending order

Tags: array, sorting

Examples

Sort numbers

Input:

{}

Rule:

{
"sort": [
[
3,
1,
4,
1,
5
]
]
}

Output:

[
1,
1,
3,
4,
5
]

sort_by

Title: Sort By

Category: array

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Sort array of objects by property

Tags: array, sorting

Examples

Sort objects by age

Input:

{}

Rule:

{
"sort_by": [
[
{
"name": "John",
"age": 25
},
{
"name": "Jane",
"age": 20
}
],
"age"
]
}

Output:

[
{
"name": "Jane",
"age": 20
},
{
"name": "John",
"age": 25
}
]

find

Title: Find

Category: array

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Find first element matching a rule

Tags: array, search

Examples

Find first even number

Input:

{}

Rule:

{
"find": [
[
1,
3,
4,
5,
6
],
{
"==": [
{
"%": [
{
"var": ""
},
2
]
},
0
]
}
]
}

Output:

4

find_index

Title: Find Index

Category: array

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Find index of first element matching a rule

Tags: array, search

Examples

Find index of first even number

Input:

{}

Rule:

{
"find_index": [
[
1,
3,
4,
5,
6
],
{
"==": [
{
"%": [
{
"var": ""
},
2
]
},
0
]
}
]
}

Output:

2

group_by

Title: Group By

Category: array

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Group array of objects by property

Tags: array, aggregation

Examples

Group by category

Input:

{}

Rule:

{
"group_by": [
[
{
"name": "apple",
"type": "fruit"
},
{
"name": "carrot",
"type": "vegetable"
},
{
"name": "banana",
"type": "fruit"
}
],
"type"
]
}

Output:

{
"fruit": [
{
"name": "apple",
"type": "fruit"
},
{
"name": "banana",
"type": "fruit"
}
],
"vegetable": [
{
"name": "carrot",
"type": "vegetable"
}
]
}

intersection

Title: Intersection

Category: array

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n*m)

Find common elements across multiple arrays

Tags: array, set

Examples

Find common elements

Input:

{}

Rule:

{
"intersection": [
[
1,
2,
3
],
[
2,
3,
4
],
[
3,
4,
5
]
]
}

Output:

[
3
]

difference

Title: Difference

Category: array

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n*m)

Elements in first array not in second array

Tags: array, set

Examples

Find elements in A not in B

Input:

{}

Rule:

{
"difference": [
[
1,
2,
3,
4
],
[
3,
4,
5
]
]
}

Output:

[
1,
2
]

union

Title: Union

Category: array

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Combine all unique elements from multiple arrays

Tags: array, set

Examples

Combine unique elements

Input:

{}

Rule:

{
"union": [
[
1,
2,
3
],
[
3,
4,
5
],
[
5,
6
]
]
}

Output:

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

auth

auth_is_authenticated

Title: Is Authenticated

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Returns true if the user has a valid authentication context

Tags: auth, authentication, policy

Examples

Authenticated user

Input:

{
"auth": {
"sub": "user-123",
"provider": "supabase"
}
}

Rule:

{
"auth_is_authenticated": []
}

Output:

true

Unauthenticated user

Input:

{
"auth": {}
}

Rule:

{
"auth_is_authenticated": []
}

Output:

false

auth_has_role

Title: Has Role

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Returns true if the user has the specified role

Tags: auth, rbac, role, policy

Examples

User has admin role

Input:

{
"auth": {
"sub": "user-123",
"roles": [
"admin",
"editor"
]
}
}

Rule:

{
"auth_has_role": [
"admin"
]
}

Output:

true

User does not have role

Input:

{
"auth": {
"sub": "user-123",
"roles": [
"viewer"
]
}
}

Rule:

{
"auth_has_role": [
"admin"
]
}

Output:

false

auth_has_any_role

Title: Has Any Role

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n*m)

Returns true if the user has any of the specified roles

Tags: auth, rbac, role, policy

Examples

User has one of the roles

Input:

{
"auth": {
"sub": "user-123",
"roles": [
"editor"
]
}
}

Rule:

{
"auth_has_any_role": [
[
"admin",
"editor"
]
]
}

Output:

true

User has none of the roles

Input:

{
"auth": {
"sub": "user-123",
"roles": [
"viewer"
]
}
}

Rule:

{
"auth_has_any_role": [
[
"admin",
"editor"
]
]
}

Output:

false

auth_has_all_roles

Title: Has All Roles

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n*m)

Returns true if the user has all of the specified roles

Tags: auth, rbac, role, policy

Examples

User has all roles

Input:

{
"auth": {
"sub": "user-123",
"roles": [
"admin",
"editor",
"viewer"
]
}
}

Rule:

{
"auth_has_all_roles": [
[
"admin",
"editor"
]
]
}

Output:

true

User missing one role

Input:

{
"auth": {
"sub": "user-123",
"roles": [
"editor",
"viewer"
]
}
}

Rule:

{
"auth_has_all_roles": [
[
"admin",
"editor"
]
]
}

Output:

false

auth_has_permission

Title: Has Permission

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Returns true if the user has the specified permission

Tags: auth, rbac, permission, policy

Examples

User has permission

Input:

{
"auth": {
"sub": "user-123",
"permissions": [
"tasks:create",
"tasks:read"
]
}
}

Rule:

{
"auth_has_permission": [
"tasks:create"
]
}

Output:

true

User lacks permission

Input:

{
"auth": {
"sub": "user-123",
"permissions": [
"tasks:read"
]
}
}

Rule:

{
"auth_has_permission": [
"tasks:delete"
]
}

Output:

false

auth_has_any_permission

Title: Has Any Permission

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n*m)

Returns true if the user has any of the specified permissions

Tags: auth, rbac, permission, policy

Examples

User has one of the permissions

Input:

{
"auth": {
"sub": "user-123",
"permissions": [
"tasks:read"
]
}
}

Rule:

{
"auth_has_any_permission": [
[
"tasks:create",
"tasks:read"
]
]
}

Output:

true

auth_has_all_permissions

Title: Has All Permissions

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n*m)

Returns true if the user has all of the specified permissions

Tags: auth, rbac, permission, policy

Examples

User has all permissions

Input:

{
"auth": {
"sub": "user-123",
"permissions": [
"tasks:create",
"tasks:read",
"tasks:delete"
]
}
}

Rule:

{
"auth_has_all_permissions": [
[
"tasks:create",
"tasks:read"
]
]
}

Output:

true

auth_claim_equals

Title: Claim Equals

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Returns true if the specified claim equals the expected value

Tags: auth, claims, policy

Examples

Email verified claim

Input:

{
"auth": {
"sub": "user-123",
"claims": {
"email_verified": true
}
}
}

Rule:

{
"auth_claim_equals": [
"email_verified",
true
]
}

Output:

true

auth_claim_includes

Title: Claim Includes

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Returns true if the claim (string or array) includes the specified token

Tags: auth, claims, policy

Examples

Groups claim includes admin

Input:

{
"auth": {
"sub": "user-123",
"claims": {
"groups": "admin editor viewer"
}
}
}

Rule:

{
"auth_claim_includes": [
"groups",
"admin"
]
}

Output:

true

Array claim includes value

Input:

{
"auth": {
"sub": "user-123",
"claims": {
"teams": [
"engineering",
"product"
]
}
}
}

Rule:

{
"auth_claim_includes": [
"teams",
"engineering"
]
}

Output:

true

auth_is_owner

Title: Is Owner

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Returns true if the authenticated user ID matches the value at the specified path

Tags: auth, ownership, policy

Examples

User owns the resource

Input:

{
"auth": {
"sub": "user-123"
},
"input": {
"ownerId": "user-123"
}
}

Rule:

{
"auth_is_owner": [
"input.ownerId"
]
}

Output:

true

User does not own the resource

Input:

{
"auth": {
"sub": "user-123"
},
"input": {
"ownerId": "user-456"
}
}

Rule:

{
"auth_is_owner": [
"input.ownerId"
]
}

Output:

false

auth_is_tenant_member

Title: Is Tenant Member

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Returns true if the user belongs to the tenant specified at the path

Tags: auth, tenant, multitenancy, policy

Examples

User is tenant member

Input:

{
"auth": {
"sub": "user-123",
"tenantId": "tenant-abc"
},
"input": {
"tenantId": "tenant-abc"
}
}

Rule:

{
"auth_is_tenant_member": [
"input.tenantId"
]
}

Output:

true

auth_has_scope

Title: Has Scope

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Returns true if the user has the specified OAuth scope

Tags: auth, oauth, scope, policy

Examples

User has read scope

Input:

{
"auth": {
"sub": "user-123",
"scope": [
"read",
"write"
]
}
}

Rule:

{
"auth_has_scope": [
"read"
]
}

Output:

true

auth_attribute_match

Title: Attribute Match (ABAC)

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Evaluates an expresso rule against the auth context for arbitrary ABAC policies. Auth context fields (sub, roles, permissions, claims, tenantId, orgId, scope) are available as top-level variables.

Tags: auth, abac, policy

Examples

Complex ABAC rule checking claims

Input:

{
"auth": {
"sub": "user-123",
"claims": {
"department": "engineering",
"level": 5
}
}
}

Rule:

{
"auth_attribute_match": [
{
"and": [
{
"==": [
{
"var": "claims.department"
},
"engineering"
]
},
{
">=": [
{
"var": "claims.level"
},
3
]
}
]
}
]
}

Output:

true

auth_deny

Title: Deny

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Unconditionally denies access, optionally with a reason

Tags: auth, policy, deny

Examples


auth_allow

Title: Allow

Category: auth

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Unconditionally allows access

Tags: auth, policy, allow

Examples

Always allow

Input:

{}

Rule:

{
"auth_allow": []
}

Output:

true

comparisons

==

Title: Equals (Loose)

Category: comparisons

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(1)

Loose equality comparison using ==

Tags: comparison, equality, basic

Examples

String equals number (loose)

Input:

{}

Rule:

{
"==": [
1,
"1"
]
}

Output:

true

Different types but equal value

Input:

{}

Rule:

{
"==": [
true,
1
]
}

Output:

true

===

Title: Equals (Strict)

Category: comparisons

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(1)

Strict equality comparison using ===

Tags: comparison, equality, basic

Examples

String does not strictly equal number

Input:

{}

Rule:

{
"===": [
1,
"1"
]
}

Output:

false

Same type and value

Input:

{}

Rule:

{
"===": [
1,
1
]
}

Output:

true

!=

Title: Not Equals (Loose)

Category: comparisons

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(1)

Loose inequality comparison using !=

Tags: comparison, equality, basic

Examples

String does not loosely equal number

Input:

{}

Rule:

{
"!=": [
1,
"2"
]
}

Output:

true

Different values

Input:

{}

Rule:

{
"!=": [
1,
2
]
}

Output:

true

!==

Title: Not Equals (Strict)

Category: comparisons

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(1)

Strict inequality comparison using !==

Tags: comparison, equality, basic

Examples

String strictly not equal to number

Input:

{}

Rule:

{
"!==": [
1,
"1"
]
}

Output:

true

Different values

Input:

{}

Rule:

{
"!==": [
1,
2
]
}

Output:

true

crypto

hash

Title: Hash

Category: crypto

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Compute hash of a string using specified algorithm (SHA-1, SHA-256, SHA-384, SHA-512)

Tags: crypto, hash, security, async

Examples

SHA-256 hash

Input:

{}

Rule:

{
"hash": [
"SHA-256",
"Hello, World!"
]
}

Output:

"dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f"

SHA-1 hash

Input:

{}

Rule:

{
"hash": [
"SHA-1",
"Hello, World!"
]
}

Output:

"0a0a9f2a6772942557ab5355d76af442f8f65e01"

hmac

Title: HMAC

Category: crypto

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Compute HMAC signature of a message using specified algorithm and key

Tags: crypto, hmac, security, async

Examples

HMAC-SHA256 signature

Input:

{}

Rule:

{
"hmac": [
"SHA-256",
"key",
"data"
]
}

Output:

"5031fe3d989c6d1537a013fa6e739da23463fdaec3b70137d828e36ace221bd0"

uuid_generate

Title: Generate UUID

Category: crypto

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Generate a random UUID v4

Tags: crypto, uuid, identifier

Examples

Generate UUID

Input:

{}

Rule:

{
"uuid_generate": []
}

Output:

{}

uuid_validate

Title: Validate UUID

Category: crypto

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Validate if a string is a valid UUID v4 format

Tags: crypto, uuid, validation

Examples

Valid UUID

Input:

{}

Rule:

{
"uuid_validate": [
"550e8400-e29b-41d4-a716-446655440000"
]
}

Output:

true

Invalid UUID

Input:

{}

Rule:

{
"uuid_validate": [
"not-a-uuid"
]
}

Output:

false

base64_encode

Title: Base64 Encode

Category: crypto

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Encode a string to Base64

Tags: crypto, base64, encoding

Examples

Encode string

Input:

{}

Rule:

{
"base64_encode": [
"Hello, World!"
]
}

Output:

"SGVsbG8sIFdvcmxkIQ=="

base64_decode

Title: Base64 Decode

Category: crypto

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Decode a Base64 string

Tags: crypto, base64, decoding

Examples

Decode Base64

Input:

{}

Rule:

{
"base64_decode": [
"SGVsbG8sIFdvcmxkIQ=="
]
}

Output:

"Hello, World!"

data-access

var

Title: Variable

Category: data-access

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Access nested data by path, parent scopes with ../, and iteration metadata

Tags: data, access, basic

Examples

Access nested property

Input:

{
"user": {
"name": "John",
"age": 25
}
}

Rule:

{
"var": "user.name"
}

Output:

"John"

Access with default value

Input:

{
"user": {
"name": "John"
}
}

Rule:

{
"var": [
"user.email",
"default@example.com"
]
}

Output:

"default@example.com"

Access parent scope with ../

Input:

{
"multiplier": 10
}

Rule:

{
"map": [
[
1,
2,
3
],
{
"+": [
{
"var": ""
},
{
"var": "../multiplier"
}
]
}
]
}

Output:

[
11,
12,
13
]

Access iteration metadata @index

Input:

{}

Rule:

{
"map": [
[
"a",
"b",
"c"
],
{
"var": "@index"
}
]
}

Output:

[
0,
1,
2
]

Access iteration metadata @first

Input:

{}

Rule:

{
"map": [
[
1,
2,
3
],
{
"var": "@first"
}
]
}

Output:

[
true,
false,
false
]

Access iteration metadata @last

Input:

{}

Rule:

{
"map": [
[
1,
2,
3
],
{
"var": "@last"
}
]
}

Output:

[
false,
false,
true
]

Access iteration metadata @total

Input:

{}

Rule:

{
"map": [
[
1,
2,
3,
4,
5
],
{
"var": "@total"
}
]
}

Output:

[
5,
5,
5,
5,
5
]

missing

Title: Missing

Category: data-access

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Check if any fields are missing (null or undefined)

Tags: validation, data, basic

Examples

Check if field is missing

Input:

{
"user": {
"name": "John"
}
}

Rule:

{
"missing": [
[
"user.email",
"user.phone"
]
]
}

Output:

true

Check if all fields present

Input:

{
"user": {
"name": "John",
"email": "john@example.com",
"phone": "555-1234"
}
}

Rule:

{
"missing": [
[
"user.email",
"user.phone"
]
]
}

Output:

false

missing_some

Title: Missing Some

Category: data-access

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Check if at least N fields are missing

Tags: validation, data

Examples

Check if at least 2 fields missing

Input:

{
"user": {
"name": "John"
}
}

Rule:

{
"missing_some": [
2,
[
"user.email",
"user.phone",
"user.address"
]
]
}

Output:

{
"missing": [
"user.email",
"user.phone",
"user.address"
],
"present": 0,
"count": 2
}

date

to_datetime

Title: To Datetime

Category: date

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(1)

Convert timestamp or date string to ISO datetime

Tags: date, parsing

Examples

Convert epoch seconds to ISO

Input:

{}

Rule:

{
"to_datetime": [
0
]
}

Output:

"1970-01-01T00:00:00.000Z"

Convert date string to ISO

Input:

{}

Rule:

{
"to_datetime": [
"2024-01-15"
]
}

Output:

"2024-01-15T00:00:00.000Z"

now

Title: Now

Category: date

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Current timestamp

Tags: time, timestamp

Examples


date_parse

Title: Date Parse

Category: date

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Parse date string to ISO format

Tags: date, parsing

Examples

Parse date string

Input:

{}

Rule:

{
"date_parse": [
"2024-01-15"
]
}

Output:

"2024-01-15T00:00:00.000Z"

date_format

Title: Date Format

Category: date

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Format date string using custom format. Supports: %Y (year), %m (month), %d (day), %H (hour), %M (minute), %S (second)

Tags: date, formatting

Examples

Format date to custom format

Input:

{}

Rule:

{
"date_format": [
"2024-01-15T10:30:00.000Z",
"%Y-%m-%d %H:%M:%S"
]
}

Output:

"2024-01-15 10:30:00"

date_add

Title: Date Add

Category: date

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Add time to a date. Supported units: years, months, days, hours, minutes, seconds

Tags: date, arithmetic

Examples

Add 7 days to date

Input:

{}

Rule:

{
"date_add": [
"2024-01-15",
7,
"days"
]
}

Output:

"2024-01-22T00:00:00.000Z"

date_diff

Title: Date Diff

Category: date

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Calculate difference between two dates in specified unit

Tags: date, arithmetic

Examples

Days between two dates

Input:

{}

Rule:

{
"date_diff": [
"2024-01-22",
"2024-01-15",
"days"
]
}

Output:

7

date_between

Title: Date Between

Category: date

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if date is between start and end dates (inclusive)

Tags: date, comparison

Examples

Check if date is in range

Input:

{}

Rule:

{
"date_between": [
"2024-01-20",
"2024-01-15",
"2024-01-25"
]
}

Output:

true

is_weekday

Title: Is Weekday

Category: date

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if date is a weekday (Monday-Friday)

Tags: date, validation

Examples

Check if Monday is weekday

Input:

{}

Rule:

{
"is_weekday": [
"2024-01-15"
]
}

Output:

true

is_weekend

Title: Is Weekend

Category: date

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if date is a weekend (Saturday-Sunday)

Tags: date, validation

Examples

Check if Saturday is weekend

Input:

{}

Rule:

{
"is_weekend": [
"2024-01-13"
]
}

Output:

true

logic

or

Title: Or

Category: logic

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Logical OR with short-circuit evaluation

Tags: logic, boolean, basic

Examples

One value true

Input:

{}

Rule:

{
"or": [
false,
true,
false
]
}

Output:

true

All values false

Input:

{}

Rule:

{
"or": [
false,
false,
false
]
}

Output:

false

and

Title: And

Category: logic

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Logical AND with short-circuit evaluation

Tags: logic, boolean, basic

Examples

All values true

Input:

{}

Rule:

{
"and": [
true,
true,
true
]
}

Output:

true

One value false

Input:

{}

Rule:

{
"and": [
true,
false,
true
]
}

Output:

false

!

Title: Not

Category: logic

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(1)

Logical NOT operator

Tags: logic, boolean, basic

Examples

Not true

Input:

{}

Rule:

{
"!": [
true
]
}

Output:

false

Not false

Input:

{}

Rule:

{
"!": [
false
]
}

Output:

true

!!

Title: Double Not

Category: logic

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(1)

Double logical NOT (converts to boolean)

Tags: logic, boolean, basic

Examples

Truthy value

Input:

{}

Rule:

{
"!!": [
"hello"
]
}

Output:

true

Falsy value

Input:

{}

Rule:

{
"!!": [
""
]
}

Output:

false

if

Title: If

Category: logic

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Conditional operator - supports if/then/elseif/then/.../else pattern. Returns the first then value whose condition is truthy, or final else value.

Tags: control-flow, conditional, basic

Examples

True condition

Input:

{}

Rule:

{
"if": [
true,
"yes",
"no"
]
}

Output:

"yes"

False condition

Input:

{}

Rule:

{
"if": [
false,
"yes",
"no"
]
}

Output:

"no"

Multiple conditions (if/elseif/else)

Input:

{
"temp": 55
}

Rule:

{
"if": [
{
"<": [
{
"var": "temp"
},
0
]
},
"freezing",
{
"<": [
{
"var": "temp"
},
100
]
},
"liquid",
"gas"
]
}

Output:

"liquid"

switch

Title: Switch

Category: logic

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Switch/case operator with fall-through default

Tags: control-flow, conditional

Examples

First matching case

Input:

{
"value": 2
}

Rule:

{
"switch": [
{
"==": [
{
"var": "value"
},
1
]
},
"one",
{
"==": [
{
"var": "value"
},
2
]
},
"two",
"other"
]
}

Output:

"two"

ternary

Title: Ternary

Category: logic

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Ternary operator (condition ? then : else)

Tags: control-flow, conditional

Examples

True condition

Input:

{}

Rule:

{
"ternary": [
true,
"yes",
"no"
]
}

Output:

"yes"

coalesce

Title: Coalesce

Category: logic

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Returns first non-null/undefined value

Tags: logic, null-handling

Examples

First non-null value

Input:

{}

Rule:

{
"coalesce": [
null,
null,
"default",
"other"
]
}

Output:

"default"

default

Title: Default

Category: logic

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Returns value or default if null/undefined

Tags: logic, null-handling

Examples

Value is null, return default

Input:

{}

Rule:

{
"default": [
null,
"default"
]
}

Output:

"default"

try

Title: Try

Category: logic

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Enhanced try-catch with type and pattern matching. Supports simple fallback or multiple catch handlers with type matching, pattern matching, or both.

Tags: error-handling, control-flow

Examples

Simple fallback

Input:

{}

Rule:

{
"try": [
42,
"error"
]
}

Output:

42

Type-based catching

Input:

{}

Rule:

{
"try": [
{
"throw": [
"Not found",
"ERR_NOT_FOUND",
"DataError"
]
},
{
"type": "DataError",
"handler": "Data error handler"
},
{
"type": "ValidationError",
"handler": "Validation error handler"
},
"Default fallback"
]
}

Output:

"Data error handler"

Pattern matching

Input:

{}

Rule:

{
"try": [
{
"throw": [
"Missing field",
"ERR_MISSING"
]
},
{
"matches": ".*missing.*",
"handler": "Missing handler"
},
{
"matches": "ERR_INVALID.*",
"handler": "Invalid handler"
},
"Default fallback"
]
}

Output:

"Missing handler"

throw

Title: Throw

Category: logic

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Throw a custom error with optional code, severity, and type. Supports multiple syntax forms: string, [message], [message, code], [message, code, severity], or {message, code, severity, type}

Tags: error-handling, control-flow

Examples


xor

Title: Xor

Category: logic

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Exclusive OR - returns true if exactly one operand is truthy

Tags: logic, boolean

Examples

Exactly one true

Input:

{}

Rule:

{
"xor": [
true,
false,
false
]
}

Output:

true

Multiple true

Input:

{}

Rule:

{
"xor": [
true,
true,
false
]
}

Output:

false

None true

Input:

{}

Rule:

{
"xor": [
false,
false,
false
]
}

Output:

false

implies

Title: Implies

Category: logic

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Logical implication - returns true if p is false or q is true (equivalent to !p || q)

Tags: logic, boolean

Examples

True implies true

Input:

{}

Rule:

{
"implies": [
true,
true
]
}

Output:

true

True implies false

Input:

{}

Rule:

{
"implies": [
true,
false
]
}

Output:

false

False implies anything

Input:

{}

Rule:

{
"implies": [
false,
true
]
}

Output:

true

VIP implies premium

Input:

{
"vip": true,
"premium": true
}

Rule:

{
"implies": [
{
"var": "vip"
},
{
"var": "premium"
}
]
}

Output:

true

assert

Title: Assert

Category: logic

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Assert operator - throws an error if condition is falsy, otherwise returns the condition value. Useful for precondition validation.

Tags: error-handling, validation, control-flow

Examples

Condition is true, return value

Input:

{}

Rule:

{
"assert": [
true,
"This should not throw"
]
}

Output:

true

Validate field exists

Input:

{
"user": {
"name": "John"
}
}

Rule:

{
"assert": [
{
"var": "user.name"
},
[
"User name is required",
"ERR_MISSING_NAME"
]
]
}

Output:

"John"

misc

log

Title: Log

Category: misc

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Console log

Tags: utility, debugging

Examples


!exists

Title: Not Exists

Category: misc

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(1)

Check if value is null or undefined

Tags: validation

Examples

Check if value does not exist

Input:

{
"value": null
}

Rule:

{
"!exists": [
{
"var": "value"
}
]
}

Output:

true

Check if value exists

Input:

{
"value": 42
}

Rule:

{
"!exists": [
{
"var": "value"
}
]
}

Output:

false

numeric

greater-than

Title: Greater Than

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Checks if first number is greater than second

Tags: comparison, basic

Aliases: >

Examples

5 > 3

Input:

{}

Rule:

{
"greater-than": [
5,
3
]
}

Output:

true

3 > 5

Input:

{}

Rule:

{
"greater-than": [
3,
5
]
}

Output:

false

>

Title: Greater Than

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Checks if first number is greater than second

Tags: comparison, basic

Aliases: >

Examples

5 > 3

Input:

{}

Rule:

{
"greater-than": [
5,
3
]
}

Output:

true

3 > 5

Input:

{}

Rule:

{
"greater-than": [
3,
5
]
}

Output:

false

greater-equal

Title: Greater Than or Equal

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Checks if first number is greater than or equal to second

Tags: comparison, basic

Aliases: >=

Examples

5 >= 5

Input:

{}

Rule:

{
"greater-equal": [
5,
5
]
}

Output:

true

3 >= 5

Input:

{}

Rule:

{
"greater-equal": [
3,
5
]
}

Output:

false

>=

Title: Greater Than or Equal

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Checks if first number is greater than or equal to second

Tags: comparison, basic

Aliases: >=

Examples

5 >= 5

Input:

{}

Rule:

{
"greater-equal": [
5,
5
]
}

Output:

true

3 >= 5

Input:

{}

Rule:

{
"greater-equal": [
3,
5
]
}

Output:

false

less-than

Title: Less Than

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Checks if first number is less than second

Tags: comparison, basic

Aliases: <

Examples

3 < 5

Input:

{}

Rule:

{
"less-than": [
3,
5
]
}

Output:

true

5 < 3

Input:

{}

Rule:

{
"less-than": [
5,
3
]
}

Output:

false

<

Title: Less Than

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Checks if first number is less than second

Tags: comparison, basic

Aliases: <

Examples

3 < 5

Input:

{}

Rule:

{
"less-than": [
3,
5
]
}

Output:

true

5 < 3

Input:

{}

Rule:

{
"less-than": [
5,
3
]
}

Output:

false

less-equal

Title: Less Than or Equal

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Checks if first number is less than or equal to second

Tags: comparison, basic

Aliases: <=

Examples

5 <= 5

Input:

{}

Rule:

{
"less-equal": [
5,
5
]
}

Output:

true

5 <= 3

Input:

{}

Rule:

{
"less-equal": [
5,
3
]
}

Output:

false

<=

Title: Less Than or Equal

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Checks if first number is less than or equal to second

Tags: comparison, basic

Aliases: <=

Examples

5 <= 5

Input:

{}

Rule:

{
"less-equal": [
5,
5
]
}

Output:

true

5 <= 3

Input:

{}

Rule:

{
"less-equal": [
5,
3
]
}

Output:

false

between

Title: Between

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(1)

Checks if value is between min and max (inclusive)

Tags: comparison, range

Examples

5 between 0 and 10

Input:

{}

Rule:

{
"between": [
0,
5,
10
]
}

Output:

true

15 between 0 and 10

Input:

{}

Rule:

{
"between": [
0,
15,
10
]
}

Output:

false

min

Title: Minimum

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Returns the minimum value from an array

Tags: aggregation, basic

Examples

Min of [1, 5, 3]

Input:

{}

Rule:

{
"min": [
[
1,
5,
3
]
]
}

Output:

1

max

Title: Maximum

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Returns the maximum value from an array

Tags: aggregation, basic

Examples

Max of [1, 5, 3]

Input:

{}

Rule:

{
"max": [
[
1,
5,
3
]
]
}

Output:

5

plus

Title: Addition (Plus)

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Adds multiple numbers together

Tags: arithmetic, basic

Aliases: +

Examples

5 + 3 + 2

Input:

{}

Rule:

{
"plus": [
5,
3,
2
]
}

Output:

10

+

Title: Addition (Plus)

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Adds multiple numbers together

Tags: arithmetic, basic

Aliases: +

Examples

5 + 3 + 2

Input:

{}

Rule:

{
"plus": [
5,
3,
2
]
}

Output:

10

minus

Title: Subtraction (Minus)

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Subtracts second number from first

Tags: arithmetic, basic

Aliases: -

Examples

5 - 3

Input:

{}

Rule:

{
"minus": [
5,
3
]
}

Output:

2

-

Title: Subtraction (Minus)

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Subtracts second number from first

Tags: arithmetic, basic

Aliases: -

Examples

5 - 3

Input:

{}

Rule:

{
"minus": [
5,
3
]
}

Output:

2

multiply

Title: Multiplication

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Multiplies multiple numbers together

Tags: arithmetic, basic

Aliases: *

Examples

5 * 3

Input:

{}

Rule:

{
"multiply": [
5,
3
]
}

Output:

15

*

Title: Multiplication

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Multiplies multiple numbers together

Tags: arithmetic, basic

Aliases: *

Examples

5 * 3

Input:

{}

Rule:

{
"multiply": [
5,
3
]
}

Output:

15

divide

Title: Division

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Divides first number by second

Tags: arithmetic, basic

Aliases: /

💡 Performance Notes: Checks for division by zero

Examples

10 / 2

Input:

{}

Rule:

{
"divide": [
10,
2
]
}

Output:

5

/

Title: Division

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Divides first number by second

Tags: arithmetic, basic

Aliases: /

💡 Performance Notes: Checks for division by zero

Examples

10 / 2

Input:

{}

Rule:

{
"divide": [
10,
2
]
}

Output:

5

modulo

Title: Modulo

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Returns the remainder of division

Tags: arithmetic, basic

Aliases: %

💡 Performance Notes: Checks for modulo by zero

Examples

10 % 3

Input:

{}

Rule:

{
"modulo": [
10,
3
]
}

Output:

1

%

Title: Modulo

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Returns the remainder of division

Tags: arithmetic, basic

Aliases: %

💡 Performance Notes: Checks for modulo by zero

Examples

10 % 3

Input:

{}

Rule:

{
"modulo": [
10,
3
]
}

Output:

1

abs

Title: Absolute Value

Category: numeric

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(1)

Returns the absolute value of a number

Tags: arithmetic, basic

Examples

Absolute value of -5

Input:

{}

Rule:

{
"abs": [
-5
]
}

Output:

5

object

keys

Title: Keys

Category: object

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Get object keys

Tags: object, properties

Examples


values

Title: Values

Category: object

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Get object values

Tags: object, properties

Examples


entries

Title: Entries

Category: object

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Get object entries

Tags: object, properties

Examples


pick

Title: Pick

Category: object

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Select specific keys from an object

Tags: object, properties, transformation

Examples

Pick name and age from object

Input:

{}

Rule:

{
"pick": [
{
"name": "John",
"age": 25,
"email": "john@example.com"
},
[
"name",
"age"
]
]
}

Output:

{
"name": "John",
"age": 25
}

omit

Title: Omit

Category: object

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Remove specific keys from an object

Tags: object, properties, transformation

Examples

Omit email from object

Input:

{}

Rule:

{
"omit": [
{
"name": "John",
"age": 25,
"email": "john@example.com"
},
[
"email"
]
]
}

Output:

{
"name": "John",
"age": 25
}

merge_deep

Title: Merge Deep

Category: object

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Deep merge multiple objects together

Tags: object, merge, transformation

Examples

Deep merge two objects

Input:

{}

Rule:

{
"merge_deep": [
{
"user": {
"name": "John"
}
},
{
"user": {
"age": 25
},
"active": true
}
]
}

Output:

{
"user": {
"name": "John",
"age": 25
},
"active": true
}

get

Title: Get

Category: object

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Get a value from a nested object by path with optional default

Tags: object, properties, data-access

Examples

Get nested property

Input:

{}

Rule:

{
"get": [
{
"user": {
"profile": {
"name": "John"
}
}
},
"user.profile.name"
]
}

Output:

"John"

Get with default value

Input:

{}

Rule:

{
"get": [
{
"user": {
"name": "John"
}
},
"user.email",
"default@example.com"
]
}

Output:

"default@example.com"

set

Title: Set

Category: object

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Set a value at a nested path in an object (creates new object)

Tags: object, properties, transformation

Examples

Set nested property

Input:

{}

Rule:

{
"set": [
{
"user": {
"name": "John"
}
},
"user.age",
25
]
}

Output:

{
"user": {
"name": "John",
"age": 25
}
}

has

Title: Has

Category: object

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Check if a nested path exists in an object

Tags: object, properties, validation

Examples

Check if path exists

Input:

{}

Rule:

{
"has": [
{
"user": {
"name": "John"
}
},
"user.name"
]
}

Output:

true

Check if path does not exist

Input:

{}

Rule:

{
"has": [
{
"user": {
"name": "John"
}
},
"user.email"
]
}

Output:

false

transform

Title: Transform

Category: object

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Transform object keys and values according to specified rules

Tags: object, transformation

Examples

Convert keys to camelCase

Input:

{}

Rule:

{
"transform": [
{
"user_name": "John",
"user_age": 25
},
"camelCase",
"none"
]
}

Output:

{
"userName": "John",
"userAge": 25
}

Convert keys to snake_case

Input:

{}

Rule:

{
"transform": [
{
"userName": "John",
"userAge": 25
},
"snake_case",
"none"
]
}

Output:

{
"user_name": "John",
"user_age": 25
}

regex

regex_match

Title: Regex Match

Category: regex

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Tests if a string matches a regular expression pattern

Tags: regex, validation, string

Examples

Match email format

Input:

{}

Rule:

{
"regex_match": [
"^[\\w.-]+@[\\w.-]+\\.\\w+$",
"test@example.com"
]
}

Output:

true

Match phone number format

Input:

{}

Rule:

{
"regex_match": [
"^\\d{3}-\\d{3}-\\d{4}$",
"555-123-4567"
]
}

Output:

true

No match

Input:

{}

Rule:

{
"regex_match": [
"^\\d+$",
"abc123"
]
}

Output:

false

regex_replace

Title: Regex Replace

Category: regex

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Replaces all occurrences of a regex pattern with a replacement string

Tags: regex, string, manipulation

Examples

Replace all digits with X

Input:

{}

Rule:

{
"regex_replace": [
"\\d",
"X",
"Phone: 555-123-4567"
]
}

Output:

"Phone: XXX-XXX-XXXX"

Remove extra whitespace

Input:

{}

Rule:

{
"regex_replace": [
"\\s+",
" ",
"Hello World"
]
}

Output:

"Hello World"

Redact SSN

Input:

{}

Rule:

{
"regex_replace": [
"\\d{3}-\\d{2}-(\\d{4})",
"XXX-XX-$1",
"SSN: 123-45-6789"
]
}

Output:

"SSN: XXX-XX-6789"

regex_extract

Title: Regex Extract

Category: regex

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Extracts all capture groups from a regex match. Returns array where index 0 is the full match, and subsequent indices are capture groups.

Tags: regex, string, parsing

Examples

Extract ICD-10 code parts

Input:

{}

Rule:

{
"regex_extract": [
"^([A-Z])(\\d{2})(\\.\\d{1})?$",
"C12.3"
]
}

Output:

[
"C12.3",
"C",
"12",
".3"
]

Extract date components

Input:

{}

Rule:

{
"regex_extract": [
"^(\\d{4})-(\\d{2})-(\\d{2})$",
"2024-01-15"
]
}

Output:

[
"2024-01-15",
"2024",
"01",
"15"
]

No match returns empty array

Input:

{}

Rule:

{
"regex_extract": [
"^\\d+$",
"abc"
]
}

Output:

[]

regex_test

Title: Regex Test

Category: regex

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Boolean test for whether a string matches a regex pattern. Alias for regex_match.

Tags: regex, validation, string, boolean

Aliases: regex_matches

Examples

Test for uppercase letters only

Input:

{}

Rule:

{
"regex_test": [
"^[A-Z]+$",
"HELLO"
]
}

Output:

true

Test for URL format

Input:

{}

Rule:

{
"regex_test": [
"^https?://",
"https://example.com"
]
}

Output:

true

Test fails for invalid format

Input:

{}

Rule:

{
"regex_test": [
"^\\d{5}$",
"123456"
]
}

Output:

false

regex_matches

Title: Regex Test

Category: regex

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Boolean test for whether a string matches a regex pattern. Alias for regex_match.

Tags: regex, validation, string, boolean

Aliases: regex_matches

Examples

Test for uppercase letters only

Input:

{}

Rule:

{
"regex_test": [
"^[A-Z]+$",
"HELLO"
]
}

Output:

true

Test for URL format

Input:

{}

Rule:

{
"regex_test": [
"^https?://",
"https://example.com"
]
}

Output:

true

Test fails for invalid format

Input:

{}

Rule:

{
"regex_test": [
"^\\d{5}$",
"123456"
]
}

Output:

false

string

contains

Title: Contains

Category: string

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Check if string or array contains value

Tags: string, search, array

Examples

Check if string contains substring

Input:

{}

Rule:

{
"contains": [
"hello world",
"world"
]
}

Output:

true

!contains

Title: Not Contains

Category: string

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Check if string or array does not contain value

Tags: string, search, array

Examples

Check if string does not contain substring

Input:

{}

Rule:

{
"!contains": [
"hello world",
"planet"
]
}

Output:

true

split

Title: Split

Category: string

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Split string by delimiter

Tags: string, manipulation

Examples

Split string by comma

Input:

{}

Rule:

{
"split": [
"hello,world",
","
]
}

Output:

[
"hello",
"world"
]

Split string by space

Input:

{}

Rule:

{
"split": [
"hello world",
" "
]
}

Output:

[
"hello",
"world"
]

trim

Title: Trim

Category: string

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Remove whitespace from both ends

Tags: string, whitespace

Examples

Trim whitespace from string

Input:

{}

Rule:

{
"trim": [
" hello "
]
}

Output:

"hello"

to_lower

Title: To Lower

Category: string

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Convert to lowercase

Tags: string, case

Examples

Convert string to lowercase

Input:

{}

Rule:

{
"to_lower": [
"HELLO"
]
}

Output:

"hello"

to_upper

Title: To Upper

Category: string

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Convert to uppercase

Tags: string, case

Examples

Convert string to uppercase

Input:

{}

Rule:

{
"to_upper": [
"hello"
]
}

Output:

"HELLO"

in

Title: In

Category: string

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Check if substring/container includes value

Tags: string, search, array

Examples

Check if substring exists in string

Input:

{}

Rule:

{
"in": [
"world",
"hello world"
]
}

Output:

true

Check if value exists in array

Input:

{}

Rule:

{
"in": [
2,
[
1,
2,
3
]
]
}

Output:

true

cat

Title: Concatenate

Category: string

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Concatenate strings

Tags: string, manipulation

Examples

Concatenate strings

Input:

{}

Rule:

{
"cat": [
"hello",
" ",
"world"
]
}

Output:

"hello world"

Concatenate numbers as strings

Input:

{}

Rule:

{
"cat": [
1,
2,
3
]
}

Output:

"123"

substr

Title: Substring

Category: string

Version: 1.0.0

JsonLogic Compatible: ✅ Yes

Complexity: O(n)

Extract substring

Tags: string, extraction

Examples

Extract substring from start

Input:

{}

Rule:

{
"substr": [
"hello",
1
]
}

Output:

"ello"

Extract substring with length

Input:

{}

Rule:

{
"substr": [
"hello",
1,
2
]
}

Output:

"el"

Extract substring with negative index

Input:

{}

Rule:

{
"substr": [
"hello",
-2
]
}

Output:

"lo"

is_empty

Title: Is Empty

Category: string

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if empty

Tags: string, validation, array

Examples

Check if string is empty

Input:

{}

Rule:

{
"is_empty": [
""
]
}

Output:

true

Check if string is not empty

Input:

{}

Rule:

{
"is_empty": [
"hello"
]
}

Output:

false

Check if array is empty

Input:

{}

Rule:

{
"is_empty": [
[]
]
}

Output:

true

Check if null is empty

Input:

{}

Rule:

{
"is_empty": [
null
]
}

Output:

false

type

Title: Type

Category: string

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Get type of value

Tags: utility, type-check

Examples

Get type of string

Input:

{}

Rule:

{
"type": [
"hello"
]
}

Output:

"string"

Get type of number

Input:

{}

Rule:

{
"type": [
42
]
}

Output:

"number"

Get type of array

Input:

{}

Rule:

{
"type": [
[
1,
2,
3
]
]
}

Output:

"array"

Get type of null

Input:

{}

Rule:

{
"type": [
null
]
}

Output:

"null"

validation

unique

Title: Unique

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Check if value is unique in a projection (no existing record with this value)

Tags: validation, async, projection, unique

Examples

Check email uniqueness

Input:

{
"projections": {
"contacts": {}
}
}

Rule:

{
"unique": [
"contacts",
"email",
"test@example.com"
]
}

Output:

true

exists

Title: Exists

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Check if a record exists in a projection with the given value

Tags: validation, async, projection, exists

Examples

Check if user exists

Input:

{
"projections": {
"users": {}
}
}

Rule:

{
"exists": [
"users",
"id",
"user_123"
]
}

Output:

true

is_null

Title: Is Null

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is exactly null

Tags: validation, type-check, null

Examples

Value is null

Input:

{}

Rule:

{
"is_null": [
null
]
}

Output:

true

Value is zero

Input:

{}

Rule:

{
"is_null": [
0
]
}

Output:

false

Value is empty string

Input:

{}

Rule:

{
"is_null": [
""
]
}

Output:

false

is_undefined

Title: Is Undefined

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is exactly undefined

Tags: validation, type-check, undefined

Examples

Value is null (not undefined)

Input:

{}

Rule:

{
"is_undefined": [
null
]
}

Output:

false

Value is empty string

Input:

{}

Rule:

{
"is_undefined": [
""
]
}

Output:

false

Value is number

Input:

{}

Rule:

{
"is_undefined": [
0
]
}

Output:

false

is_nil

Title: Is Nil

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is null or undefined

Tags: validation, type-check, null, undefined

Examples

Value is null

Input:

{}

Rule:

{
"is_nil": [
null
]
}

Output:

true

Value is zero

Input:

{}

Rule:

{
"is_nil": [
0
]
}

Output:

false

Value is empty string

Input:

{}

Rule:

{
"is_nil": [
""
]
}

Output:

false

is_nan

Title: Is NaN

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is NaN (Not a Number)

Tags: validation, type-check, number

Examples

Value is NaN

Input:

{}

Rule:

{
"is_nan": [
null
]
}

Output:

true

Value is string NaN

Input:

{}

Rule:

{
"is_nan": [
"NaN"
]
}

Output:

false

Value is valid number

Input:

{}

Rule:

{
"is_nan": [
42
]
}

Output:

false

is_finite

Title: Is Finite

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is a finite number (not NaN or Infinity)

Tags: validation, type-check, number

Examples

Value is finite number

Input:

{}

Rule:

{
"is_finite": [
42
]
}

Output:

true

Value is Infinity

Input:

{}

Rule:

{
"is_finite": [
null
]
}

Output:

false

Value is NaN

Input:

{}

Rule:

{
"is_finite": [
null
]
}

Output:

false

is_integer

Title: Is Integer

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is an integer

Tags: validation, type-check, number

Examples

Value is integer

Input:

{}

Rule:

{
"is_integer": [
42
]
}

Output:

true

Value is float

Input:

{}

Rule:

{
"is_integer": [
3.14
]
}

Output:

false

Value is not a number

Input:

{}

Rule:

{
"is_integer": [
"42"
]
}

Output:

false

is_float

Title: Is Float

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is a float (has decimal part)

Tags: validation, type-check, number

Examples

Value is float

Input:

{}

Rule:

{
"is_float": [
3.14
]
}

Output:

true

Value is integer

Input:

{}

Rule:

{
"is_float": [
42
]
}

Output:

false

Value is not a number

Input:

{}

Rule:

{
"is_float": [
"3.14"
]
}

Output:

false

is_number

Title: Is Number

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if type is number (includes NaN)

Tags: validation, type-check, number

Examples

Value is number

Input:

{}

Rule:

{
"is_number": [
42
]
}

Output:

true

Value is NaN (typeof NaN is number)

Input:

{}

Rule:

{
"is_number": [
null
]
}

Output:

true

Value is string number

Input:

{}

Rule:

{
"is_number": [
"42"
]
}

Output:

false

is_finite_number

Title: Is Finite Number

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is a finite number (excludes NaN and Infinity)

Tags: validation, type-check, number

Examples

Value is finite number

Input:

{}

Rule:

{
"is_finite_number": [
42
]
}

Output:

true

Value is NaN

Input:

{}

Rule:

{
"is_finite_number": [
null
]
}

Output:

false

Value is Infinity

Input:

{}

Rule:

{
"is_finite_number": [
null
]
}

Output:

false

is_string

Title: Is String

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if type is string

Tags: validation, type-check, string

Examples

Value is string

Input:

{}

Rule:

{
"is_string": [
"hello"
]
}

Output:

true

Value is number

Input:

{}

Rule:

{
"is_string": [
42
]
}

Output:

false

Value is empty string

Input:

{}

Rule:

{
"is_string": [
""
]
}

Output:

true

is_boolean

Title: Is Boolean

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if type is boolean

Tags: validation, type-check, boolean

Examples

Value is boolean true

Input:

{}

Rule:

{
"is_boolean": [
true
]
}

Output:

true

Value is boolean false

Input:

{}

Rule:

{
"is_boolean": [
false
]
}

Output:

true

Value is truthy number

Input:

{}

Rule:

{
"is_boolean": [
1
]
}

Output:

false

is_array

Title: Is Array

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is an array

Tags: validation, type-check, array

Examples

Value is array

Input:

{}

Rule:

{
"is_array": [
[
1,
2,
3
]
]
}

Output:

true

Value is empty array

Input:

{}

Rule:

{
"is_array": [
[]
]
}

Output:

true

Value is not array

Input:

{}

Rule:

{
"is_array": [
"not array"
]
}

Output:

false

is_object

Title: Is Object

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is a plain object (not null, not array)

Tags: validation, type-check, object

Examples

Value is array

Input:

{}

Rule:

{
"is_object": [
[
1,
2,
3
]
]
}

Output:

false

Value is null

Input:

{}

Rule:

{
"is_object": [
null
]
}

Output:

false

Value is string

Input:

{}

Rule:

{
"is_object": [
"not object"
]
}

Output:

false

is_email

Title: Is Email

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Check if value matches email format

Tags: validation, format-check, email

Examples

Valid email

Input:

{}

Rule:

{
"is_email": [
"user@example.com"
]
}

Output:

true

Email with subdomain

Input:

{}

Rule:

{
"is_email": [
"user@mail.example.com"
]
}

Output:

true

Invalid email - no @

Input:

{}

Rule:

{
"is_email": [
"userexample.com"
]
}

Output:

false

Invalid email - no domain

Input:

{}

Rule:

{
"is_email": [
"user@"
]
}

Output:

false

is_url

Title: Is URL

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Check if value matches URL format (http or https)

Tags: validation, format-check, url

Examples

Valid HTTPS URL

Input:

{}

Rule:

{
"is_url": [
"https://example.com"
]
}

Output:

true

Valid HTTP URL

Input:

{}

Rule:

{
"is_url": [
"http://example.com/path"
]
}

Output:

true

Invalid URL - no protocol

Input:

{}

Rule:

{
"is_url": [
"example.com"
]
}

Output:

false

Invalid URL - not URL

Input:

{}

Rule:

{
"is_url": [
"not-a-url"
]
}

Output:

false

is_uuid

Title: Is UUID

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(n)

Check if value matches UUID v4 format

Tags: validation, format-check, uuid

Examples

Valid UUID v4

Input:

{}

Rule:

{
"is_uuid": [
"550e8400-e29b-41d4-a716-446655440000"
]
}

Output:

true

Valid UUID lowercase

Input:

{}

Rule:

{
"is_uuid": [
"550e8400-e29b-41d4-a716-446655440000"
]
}

Output:

true

Invalid UUID - wrong format

Input:

{}

Rule:

{
"is_uuid": [
"not-uuid"
]
}

Output:

false

Invalid UUID - uppercase

Input:

{}

Rule:

{
"is_uuid": [
"550E8400-E29B-41D4-A716-446655440000"
]
}

Output:

false

min_length

Title: Min Length

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if string or array has minimum length

Tags: validation, range, string, array

Examples

String meets minimum length

Input:

{}

Rule:

{
"min_length": [
"hello world",
5
]
}

Output:

true

String fails minimum length

Input:

{}

Rule:

{
"min_length": [
"abc",
5
]
}

Output:

false

Array meets minimum length

Input:

{}

Rule:

{
"min_length": [
[
1,
2,
3,
4,
5
],
3
]
}

Output:

true

Empty string fails

Input:

{}

Rule:

{
"min_length": [
"",
1
]
}

Output:

false

max_length

Title: Max Length

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if string or array has maximum length

Tags: validation, range, string, array

Examples

String meets maximum length

Input:

{}

Rule:

{
"max_length": [
"hello",
10
]
}

Output:

true

String exceeds maximum length

Input:

{}

Rule:

{
"max_length": [
"very long string",
5
]
}

Output:

false

Array meets maximum length

Input:

{}

Rule:

{
"max_length": [
[
1,
2,
3
],
5
]
}

Output:

true

range

Title: Range

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if number is within inclusive range

Tags: validation, range, number

Examples

Number within range

Input:

{}

Rule:

{
"range": [
5,
1,
10
]
}

Output:

true

Number below range

Input:

{}

Rule:

{
"range": [
0,
1,
10
]
}

Output:

false

Number above range

Input:

{}

Rule:

{
"range": [
15,
1,
10
]
}

Output:

false

Number at boundary

Input:

{}

Rule:

{
"range": [
10,
1,
10
]
}

Output:

true

in_range

Title: In Range

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if number is within inclusive range (alias for range)

Tags: validation, range, number

Examples

Number within range

Input:

{}

Rule:

{
"in_range": [
5,
1,
10
]
}

Output:

true

Number below range

Input:

{}

Rule:

{
"in_range": [
0,
1,
10
]
}

Output:

false

min_value

Title: Min Value

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is greater than or equal to minimum

Tags: validation, range, number

Examples

Value meets minimum

Input:

{}

Rule:

{
"min_value": [
5,
3
]
}

Output:

true

Value below minimum

Input:

{}

Rule:

{
"min_value": [
2,
3
]
}

Output:

false

Value equals minimum

Input:

{}

Rule:

{
"min_value": [
3,
3
]
}

Output:

true

max_value

Title: Max Value

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is less than or equal to maximum

Tags: validation, range, number

Examples

Value meets maximum

Input:

{}

Rule:

{
"max_value": [
5,
10
]
}

Output:

true

Value exceeds maximum

Input:

{}

Rule:

{
"max_value": [
15,
10
]
}

Output:

false

Value equals maximum

Input:

{}

Rule:

{
"max_value": [
10,
10
]
}

Output:

true

equals_length

Title: Equals Length

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if string or array has exact length

Tags: validation, range, string, array

Examples

String has exact length

Input:

{}

Rule:

{
"equals_length": [
"hello",
5
]
}

Output:

true

String has wrong length

Input:

{}

Rule:

{
"equals_length": [
"world",
3
]
}

Output:

false

Array has exact length

Input:

{}

Rule:

{
"equals_length": [
[
1,
2,
3
],
3
]
}

Output:

true

between_length

Title: Between Length

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if string or array length is within range

Tags: validation, range, string, array

Examples

String length within range

Input:

{}

Rule:

{
"between_length": [
"hello",
3,
6
]
}

Output:

true

String length below range

Input:

{}

Rule:

{
"between_length": [
"hi",
3,
6
]
}

Output:

false

Array length within range

Input:

{}

Rule:

{
"between_length": [
[
1,
2,
3,
4
],
2,
5
]
}

Output:

true

required

Title: Required

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value is present and not empty

Tags: validation, required

Examples

Value is present

Input:

{}

Rule:

{
"required": [
"hello"
]
}

Output:

true

Value is empty string

Input:

{}

Rule:

{
"required": [
""
]
}

Output:

false

Value is null

Input:

{}

Rule:

{
"required": [
null
]
}

Output:

false

matches

Title: Matches

Category: validation

Version: 1.0.0

JsonLogic Compatible: ❌ No

Complexity: O(1)

Check if value matches another value (for cross-field validation)

Tags: validation, comparison, cross-field

Examples

Values match

Input:

{}

Rule:

{
"matches": [
"password123",
"password123"
]
}

Output:

true

Values do not match

Input:

{}

Rule:

{
"matches": [
"password123",
"different"
]
}

Output:

false