Contact Us 1-800-596-4880

isBlank

isBlank(text: String | Null): Boolean

Returns true if the given string is empty (""), completely composed of whitespaces, or null. Otherwise, the function returns false.

Parameters

Name Description

text

An input string to evaluate.

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.

Source

%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("")
}

Output

{
  "emptyString": true,
  "stringWithSpaces": true,
  "textString": false,
  "somePayloadValue": true,
  "nullString": true,
  "notEmptyTextString": true,
  "notEmptyTextStringTwo": false
}