File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
main/scala/org/camunda/feel/impl/builtin
test/scala/org/camunda/feel/impl/builtin Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ object StringBuiltinFunctions {
4545 " extract" -> List (extractFunction),
4646 " trim" -> List (trimFunction),
4747 " uuid" -> List (uuidFunction),
48- " to base64" -> List (toBase64Function)
48+ " to base64" -> List (toBase64Function),
49+ " is blank" -> List (isBlankFunction)
4950 )
5051
5152 private def substringFunction = builtinFunction(
@@ -287,4 +288,11 @@ object StringBuiltinFunctions {
287288 }
288289 )
289290
291+ private def isBlankFunction = builtinFunction(
292+ params = List (" string" ),
293+ invoke = {case List (ValString (string)) =>
294+ ValBoolean (string.isBlank)
295+ }
296+ )
297+
290298}
Original file line number Diff line number Diff line change @@ -195,4 +195,32 @@ class BuiltinStringFunctionsTest
195195
196196 evaluateExpression(""" to base64(value: "Camunda") """ ) should returnResult(" Q2FtdW5kYQ==" )
197197 }
198+
199+ " A is blank() function" should " return true if the string contains only whitespace" in {
200+ evaluateExpression(
201+ expression = """ is blank("") """
202+ ) should returnResult(true )
203+
204+ evaluateExpression(
205+ expression = """ is blank(" ") """
206+ ) should returnResult(true )
207+
208+ evaluateExpression(
209+ expression = """ is blank("\t\n\r\f") """
210+ ) should returnResult(true )
211+
212+ evaluateExpression(
213+ expression = """ is blank(string: "") """
214+ ) should returnResult(true )
215+ }
216+
217+ it should " return false if the string contains only non-whitespace characters" in {
218+ evaluateExpression(
219+ expression = """ is blank("hello world") """
220+ ) should returnResult(false )
221+
222+ evaluateExpression(
223+ expression = """ is blank(" hello world ") """
224+ ) should returnResult(false )
225+ }
198226}
You can’t perform that action at this time.
0 commit comments