%dw 2.0
output application/json
var someString = "something"
var nullString = null
---
{
// checking if the string is blank
"emptyString" : isBlank(""),
"stringWithSpaces" : isBlank(" "),
"textString" : isBlank(someString),
"somePayloadValue" : isBlank(payload.nonExistingValue),
"nullString" : isBlank(nullString),
// checking if the string is not blank
"notEmptyTextString" : not isBlank(" 1234"),
"notEmptyTextStringTwo" : ! isBlank("")
}
isBlank
isBlank(String | Null): Boolean
Returns true
if the given string is empty (""
), completely composed of whitespaces, or null
. Otherwise, the function returns false
.
Example
This example indicates whether the given values are blank. It also
uses the not
and !
operators to check that a value is not blank.
The !
operator is supported starting in Dataweave 2.2.0. Use !
only in Mule 4.2 and later versions.