To get a v4 UUID in DataWeave we must use the function uuid
from the dw::Core
module. The function simply returns a value that is created using random numbers. So each time we invoke the function we will get a different value.
Continue reading →
DataWeave has a standard function to join array elements into a string value: joinBy
in the dw::Core
module. The joinBy
function takes an array as first argument and a string value that is used as separator. The array should have string values or values that can be coerced into string values.
Continue reading →
If we want to wrap a string value with another string value we can use the wrapWith
and wrapIfMissing
functions defined in the dw::core::Strings
module. The first argument of these functions is the string we want to wrap and the second argument is the string value that wraps the first argument. The function wrapIfMissing
will only apply the wrapper string if it was not already applied.
To remove a wrapped character from a wrapped string we can use the unwrap
function. The first argument is the string value that is already wrapped and the second argument the character we want to use for unwrapping. The second argument can only be a single character, but we can repeatedly invoke the unwrap
function to remove multiple wrap characters.
Continue reading →
DataWeave has several function to find the highest or lowest value in an array. The items in the array need to be of the same type and implement the Comparable
interface. To find the highest value we can use the max
function. The function returns the maximum value based on the type of the item in the array. If we want to find the highest value based on other criteria we can use the maxBy
function. This function takes a lambda as last argument where we can return a Comparable
value that is used to determine the highest value. To find the lowest value in an array we have similar functions: min
and minBy
.
Continue reading →
DataWeave 2.4 introduced the reverse
function in the Strings
module. With this function we reverse the string value that we pass in as argument. The result is the reversed string.
Continue reading →
The Strings
module in DataWeave has some very useful functions to work with string values. For example to repeat a string value we can use the repeat
function. The first argument is the string value we want to repeat and the second argument the number of times the value must be repeated.
Continue reading →