$$boolean
Evaluates input to boolean using the Truthy logic
Usage​
{
"$$boolean": /* input */,
"style": "JAVA" /* or JS */
}
"$$boolean([style]):{input}"
note
Concrete values in the usage example are default values.
Strings evaluation depends on style
argument:
- By default, value must be
"true"
fortrue
. - Unless
style
is set toJS
, then any non-empty value istrue
. Arrays and objects of size 0 returnsfalse
.
Returns​
boolean
Arguments​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | any | null | ||
style | enum | JAVA / JS | JAVA | Style of considering truthy values (JS only relates to string handling; not objects and arrays) |
Examples​
Input
Definition
Output
true
"$$boolean:$"
true
"0"
"$$boolean(js):$"
true
"false"
"$$boolean(js):$"
true
"true"
"$$boolean:$"
true
"True"
"$$boolean:$"
true
"true"
"$$boolean(JS):$"
true
1
"$$boolean:$"
true
-1
"$$boolean:$"
true
{
"": 0
}
"$$boolean:$"
true
[
0
]
"$$boolean:$"
true
false
"$$boolean:$"
false
""
"$$boolean:$"
false
""
"$$boolean(js):$"
false
"0"
"$$boolean:$"
false
"false"
"$$boolean:$"
false
"False"
"$$boolean:$"
false
0
"$$boolean:$"
false
null
"$$boolean:$"
false
{}
"$$boolean:$"
false
[]
"$$boolean:$"
false
"true"
{
"$$boolean": "$",
"style": "JS"
}
true
"false"
{
"$$boolean": "$",
"style": "js"
}
true
"false"
{
"$$boolean": "$"
}
false