Contact Free trial Login

isBlank

isBlank(String | Null): Boolean

Returns true if the given string is empty or completely composed of whitespace, false if not.

Parameters

Name Description

text

A 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.

Source

%dw 2.0
output  application/json
---
{
  "empty" : isBlank(""),
  "withSpaces" : isBlank("      "),
  "withText" : isBlank(" 1223"),
  // not blank
  "checkNotEmpty" : not isBlank(" 1234"),
  // ! for not in DataWeave 2.2.0 for Mule 4.2 and later
  "checkNotEmptyTwo" : ! isBlank(" 1234")
}

Output

{
  "empty": true,
  "withSpaces": true,
  "withText": false,
  "checkNotEmpty": true,
  "checkNotEmptyTwo": true
}