XVal Library
The XVal library is accessible through the lib name
Function
Description
Example
List functions
nth [n] [list]
Returns the nth element of list
enumerate []
Returns a list of pairs [n, x] where n is the index of element x
fst [pair]
Returns the first element of pair where pair is a list of two elements
snd [pair]
Returns the second element of pair where pair is a list of two elements
length [list]
Returns the number of elements in list
exists [test] [list]
Returns true if the supplied function test returns true when applied to one element in list
flatten [nested-list]
Flattens one level of a 2-deep nested list
lib.flatten [ [a,b], [1,2] ] // returns: [ a, b, 1, 2 ]
listConcat [list1] [list2]
Returns a single list containing first all the elements of list1 and then all the elements of list2
guardLength [max-length message text]
Validates that text is no more than max-length characters long and throws an error with message if the check fails.
General functions
toString [value]
Returns a string representation of value
raiseError [message]
Throws an exception, throwing message
Date time functions
datetime.normalizeDate [date]
Returns date as a YYYY-MM-DD string
datetime.localizeDate [date]
Returns date as on the local culture format
datetime.today
Returns today’s date in YYYY-MM-DD format
datetime.addDays [date days]
Calculates a future (or past, if days is negative) date
datetime.fromAppInfo [day: AppInfo]
Converts a string in a Centara AppInfo (blob) format to a datetime object
datetime.toAppInfo [day: DateTime]
Converts a datetime object to a Centara AppInfo (blob) format
datetime.fromMacro [day: String]
Converts a string in a Centara macro format to a datetime object
datetime.toMacro [day: DateTime]
Converts a datetime object to a Centara macro format
String functions
string.toUpper [text]
Returns text in upper case
string.toLower [text]
Returns text in lower case
string.startsWith [value text]
Tests if text starts with value
string.endsWith [value text]
Tests if text ends with value
string.contains [value text]
Tests if text contains value
string.length [text]
Returns the number of characters in text
Regex functions
regex.test [pattern text]
Tests if the pattern regular expression matches text
regex.split [text]
Splits text using the pattern regular expression
regex.replace [pattern replacement text]
Replace pattern with replacement in text
Last updated
Was this helpful?