isbool
This page explains how to use the isbool function in APL.
Use the isbool function to check whether an expression evaluates to a boolean value. This is helpful when you need to validate data types, filter boolean values, or handle type checking in conditional logic.
You typically use isbool when working with dynamic or mixed-type data where you need to verify that a value is actually a boolean before performing boolean operations or conversions.
Usage
Syntax
isbool(expression)Parameters
| Name | Type | Description |
|---|---|---|
| expression | dynamic | The expression to check for boolean type. |
Returns
Returns true if the expression value is a boolean, false otherwise.
Use case examples
Validate that a field contains boolean values before using it in boolean operations or filters.
Query
Output
| _time | uri | status | is_cached | cache_hit |
|---|---|---|---|---|
| Jun 24, 09:28:10 | /api/users | 200 | true | true |
This example creates a boolean field and validates it using isbool before using it in further boolean operations, ensuring type safety in your queries.
Check if trace attributes contain boolean values before performing boolean logic on them.
Query
Output
| _time | trace_id | service.name | is_error | error_occurred |
|---|---|---|---|---|
| Jun 24, 09:28:10 | abc123 | frontend | false | false |
This example validates that a computed boolean value is actually a boolean type before using it in conditional logic, preventing type-related errors.
Validate boolean flags in security events to ensure they contain proper boolean values before filtering or alerting.
Query
Output
| _time | uri | status | is_suspicious | is_high_risk | security_alert |
|---|---|---|---|---|---|
| Jun 24, 09:28:10 | /admin | 403 | true | false | false |
This example validates multiple boolean flags before combining them in security logic, ensuring that only properly typed boolean values are used in alert conditions.
List of related functions
- tobool: Converts a value to boolean. Use
toboolto convert values to boolean, andisboolto check if a value is already a boolean. - gettype: Returns the type of a value as a string. Use
gettypewhen you need to check for multiple types, andisboolwhen you only need to check for boolean. - isnull: Checks if a value is null. Use
isnullto check for null values, andisboolto check for boolean type.