JavaScript expression functions
SimWorkflow provides a small number of functions that can be used in JavaScript expression to help process the data.
- Swf.hmacSha256Hex
- Swf.ipAddressMatches
- Swf.base64Encode
- Swf.base64Decode
- Swf.isNotBlank
- Swf.isBlank
- Swf.isNotEmpty
- Swf.isEmpty
Swf.hmacSha256Hex
Swf.hmacSha256Hex(key, data)
HmacSHA256 Message Authentication Code (MAC) for the given key String and data String.
Parameters:
-
key
- the key for the keyed digest -
data
- the data which should to digest
Returns:
- HmacSHA256 MAC for the given key and data as hex string (lowercase)
Swf.ipAddressMatches
Swf.ipAddressMatches(ipAddress, address)
Check the ipAddress
matches another address
.
Swf.ipAddressMatches("127.0.0.1/16", "127.0.0.1") = true
Swf.ipAddressMatches("127.0.0.1/16", "192.168.0.1") = false
Parameters:
-
ipAddress
- the specific IP address or a range specified using the IP/Netmask (e.g. 192.168.1.0/24 or 202.24.0.0/14) from which the address must match -
address
- the address to check for a match
Returns:
- true if the matches, false otherwise
Swf.base64Encode
Swf.base64Encode(dataToEncode)
Converts an ASCII string to a base 64 representation.
Swf.base64Encode("Data to encode") = "RGF0YSB0byBlbmNvZGU="
Parameters:
dataToEncode
- string data to encode
Returns:
- String containing Base64 characters
Swf.base64Decode
Swf.base64Decode(dataToDecode)
Converts base 64 encoded representation to an ASCII string.
Swf.base64Decode("RGF0YSB0byBlbmNvZGU=") = "Data to encode"
Parameters:
dataToDecode
- string data to decode
Returns:
- String containing decoded data
Swf.isNotBlank
Swf.isNotBlank(data)
Checks if a string data is not empty (""), not null and not whitespace only.
Swf.isNotBlank(null) = false
Swf.isNotBlank("") = false
Swf.isNotBlank(" ") = false
Swf.isNotBlank("bob") = true
Swf.isNotBlank(" bob ") = true
Parameters:
data
- string data to check, may be null
Returns:
- If the string data is not empty and not null and not whitespace only
Swf.isBlank
Swf.isBlank(data)
Checks if a string data is empty (""), null, orwhitespace only.
Swf.isBlank(null) = true
Swf.isBlank("") = true
Swf.isBlank(" ") = true
Swf.isBlank("bob") = false
Swf.isBlank(" bob ") = false
Parameters:
data
- string data to check, may be null
Returns:
- If the string data is null, empty or whitespace only
Swf.isNotEmpty
Swf.isNotEmpty(data)
Checks if a string data is not empty ("") and not null.
Swf.isNotEmpty(null) = false
Swf.isNotEmpty("") = false
Swf.isNotEmpty(" ") = true
Swf.isNotEmpty("bob") = true
Swf.isNotEmpty(" bob ") = true
Parameters:
data
- string data to check, may be null
Returns:
- If the string data is not empty and not null
Swf.isEmpty
Swf.isEmpty(data)
Checks if a string data is empty ("") or null
Swf.isEmpty(null) = true
Swf.isEmpty("") = true
Swf.isEmpty(" ") = false
Swf.isEmpty("bob") = false
Swf.isEmpty(" bob ") = false
Parameters:
data
- string data to check, may be null
Returns:
- If the string data is null or empty