Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ object StringBuiltinFunctions {
"extract" -> List(extractFunction),
"trim" -> List(trimFunction),
"uuid" -> List(uuidFunction),
"to base64" -> List(toBase64Function)
"to base64" -> List(toBase64Function),
"is blank" -> List(isBlankFunction)
)

private def substringFunction = builtinFunction(
Expand Down Expand Up @@ -287,4 +288,11 @@ object StringBuiltinFunctions {
}
)

private def isBlankFunction = builtinFunction(
params = List("string"),
invoke = {case List(ValString(string)) =>
ValBoolean(string.isBlank)
}
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,32 @@ class BuiltinStringFunctionsTest

evaluateExpression(""" to base64(value: "Camunda") """) should returnResult("Q2FtdW5kYQ==")
}

"A is blank() function" should "return true if the string contains only whitespace" in {
evaluateExpression(
expression = """ is blank("") """
) should returnResult(true)

evaluateExpression(
expression = """ is blank(" ") """
) should returnResult(true)

evaluateExpression(
expression = """ is blank("\t\n\r\f") """
) should returnResult(true)

evaluateExpression(
expression = """ is blank(string: "") """
) should returnResult(true)
}

"A is blank() function" should "return false if the string contains only non-whitespace characters" in {
evaluateExpression(
expression = """ is blank("hello world") """
) should returnResult(false)

evaluateExpression(
expression = """ is blank(" hello world ") """
) should returnResult(false)
}
}