--- title: "Template Test Functions" slug: "template-test-functions" description: "Listing of the functions available in Validatar's handlebars templating language." updated: 2025-08-22T02:20:56Z published: 2025-08-22T02:20:56Z canonical: "docs.validatar.com/template-test-functions" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.validatar.com/llms.txt > Use this file to discover all available pages before exploring further. # Template Test Functions ## Overview Template tests provide an extensive list of functions that can be referenced within the template. Functions are grouped into the following categories: - Math Functions - String Functions - Array Functions - Control Logic - Conditions ### Math Functions #### Add - add Adds two numbers. ``` #add (number) (number) ``` ``` {{#add 2 2}} ``` ``` 4 ``` #### Absolute - abs Returns the absolute value of a number. ``` #abs (number) ``` ``` {{#abs -32}} ``` ``` 32 ``` #### Ceiling - ceiling Rounds a number up to the nearest whole number. ``` #ceiling (number) ``` ``` {{#ceiling 23.215}} ``` ``` 24 ``` #### Divide - divide Divides the first number by the second number. ``` #divide (number) (number) ``` ``` {{#divide 144 12}} ``` ``` 12 ``` #### Floor - floor Rounds a number down to the nearest whole number. ``` #floor (number) ``` ``` {{#floor 23.215}} ``` ``` 23 ``` #### Modulo - mod Modulus of first number over second number. ``` #mod (number) (number) ``` ``` {{#mod 24 5}} ``` ``` 4 ``` #### Multiply - multiply Multiplies first number by second number. ``` #multiply (number) (number) ``` ``` {{#multiply 6 3}} ``` ``` 18 ``` #### Power - pow Raises first number to the power of the second number. ``` #pow (number) (number) ``` ``` {{#pow 3 3}} ``` ``` 27 ``` #### Round - round Rounds a number to the nearest whole number. ``` #round (number) ``` ``` {{#round 48.5}} ``` ``` 49 ``` #### Subtract - subtract Subtracts second number from first number. ``` #subtract (number) (number) ``` ``` {{#subtract 9 3}} ``` ``` 6 ``` #### Square Root - sqrt Returns the square root of a number. ``` #sqrt (number) ``` ``` {{#sqrt 144}} ``` ``` 12 ``` #### Increment - inc Increment a number or return a default number if missing. ``` #inc (number) (number) ``` ``` {{#inc 4}} ``` ``` 5 ``` #### Decrement - dec Decrement a number or return a default number if missing. ``` #dec (number) (number) ``` ``` {{#dec 4}} ``` ``` 3 ``` #### Counter - counter Increment a counter by an offset. Accepts three optional arguments: starting_value, offset, and counter_key. ``` #counter (number) (number) (string) ``` ``` {{#counter}} {{#counter 'counter2' 4}} {{#counter}} {{#counter 'counter2'}} ``` ``` 1 4 2 5 ``` ### String Functions #### Camelcase - camel Converts a string to camelCase. ``` #camel (string) ``` ``` {{#camel 'to be converted'}} ``` ``` toBeConverted ``` #### Capitalize - capitalize Capitalizes the first character of a string. ``` #capitalize (string) ``` ``` {{#capitalize 'capitalize this sentence.'}} ``` ``` Capitalize this sentence. ``` #### Concatenate - concat Concatenates one or more strings together. ``` #concat (string) ... (string) ``` ``` {{#concat 'foo' 'bar'}} ``` ``` foobar ``` #### Contains - contains Returns True if the specified string contains a specified substring. ``` #contains (string) (string) ``` ``` {{#contains 'hello world' 'hello'}} ``` ``` True ``` #### EndsWith - endswith Returns True if a string ends with the specified substring. ``` #endswith (string) (string) ``` ``` {{#endswith 'friend' 'end'}} ``` ``` True ``` #### Format - format Returns a string representation of a date with a specified format. ``` #format (date) (string) ``` ``` {{#format '5/1/2021 6:32:06 PM' 'dddd, MMMM dd yyyy'}} ``` ``` Saturday, May 01 2021 ``` #### Join - join Join multiple strings together with an optional delimiter. ``` #join (string[]) (string) ``` ``` // array = ['one', 'two', 'three'] {{#join array '-'}} ``` ``` one-two-three ``` #### Left - left Extracts a specified number of characters from the beginning of a string. ``` #left (string) (number) ``` ``` {{#left 'romeo' 4}} ``` ``` rome ``` #### Length - length Returns the length of the specified string. ``` #length (string) ``` ``` {{#length 'beforehand'}} ``` ``` 10 ``` #### Lowercase - lower Converts a string to lowercase. ``` #lower (string) ``` ``` {{#lower 'CUSTOMER_KEY'}} ``` ``` customer_key ``` #### Match - match Searches input string and returns index of first occurrence of the specified pattern, returns -1 if a match is not found. ``` #match (string) (string) ``` ``` {{#match 'Area Code: 817' '\b\d\d\d\b'}} ``` ``` 11 ``` #### Pascalcase - pascal Converts a string to PascalCase. ``` #pascal (string) ``` ``` {{#pascal 'high pressure'}} ``` ``` HighPressure ``` #### Prepend - prepend Prepends the second string to the beginning of the first string. ``` #prepend (string) (string) ``` ``` {{#prepend 'day' 'Fri'}} ``` ``` Friday ``` #### Remove - remove Removes matching substrings within a string. ``` #remove (string) (string) ``` ``` {{#remove 'th???e quic???k brown f???ox' '???'}} ``` ``` the quick brown fox ``` #### Replace - replace Replace matching substrings within a string with something else. ``` #replace (string) (string) (string) ``` ``` {{#replace 'This docment uses docments to docment the docmentation' 'docment' 'document'}} ``` ``` This document uses documents to document the documentation ``` #### Right - right Extracts a specified number of characters from the end of a string. ``` #right (string) (number) ``` ``` {{right 'tango' 2}} ``` ``` go ``` #### Split - split Splits a string into substrings based on a specified delimiter. ``` #split (string) (string) ``` ``` {{#list (#split 'hello,hello,hello' ',')}} '{{this}} world' {{/list}} ``` ``` 'hello world','hello world','hello world' ``` #### StartsWith - startswith Returns True if a string begins with the specified substring. ``` #startswith (string) (string) ``` ``` {{#startswith 'prefix' 'pre'}} ``` ``` True ``` #### Substring - substring Extracts a substring from a string beginning at the specified index with an optional length. ``` #substring (string) (number) (number) ``` ``` {{#substring 'foobar' 0 3}} ``` ``` foo ``` #### Titlecase - title Converts a string to Titlecase. ``` #title (string) ``` ``` {{#title 'the very hungry caterpillar'}} ``` ``` The Very Hungry Caterpillar ``` #### Trim - trim Trim whitespace from the left and right side of a string. ``` #trim (string) ``` ``` {{#trim ' lost in the middle '}} ``` ``` lost in the middle ``` #### TrimStart - trimstart Trim whitespace from the left side of a string. ``` #trimstart (string) ``` ``` {{#trimstart ' far from the beginning'}} ``` ``` far from the beginning ``` #### TrimEnd - trimend Trim whitespace from the right side of a string. ``` #trimend (string) ``` ``` {{#trimend 'the end is miles away '}} ``` ``` the end is miles away ``` #### Truncate - truncate Truncates a string to a specified number of characters. ``` #truncate (string) (number) ``` ``` {{#truncate 'the quick brown fox jumps over the lazy dog' 19}} ``` ``` the quick brown fox ``` #### Uppercase - upper Converts a string to UPPERCASE. ``` #upper (string) ``` ``` {{#upper 'from quiet to loud'}} ``` ``` FROM QUIET TO LOUD ``` #### ParseJson - parsejson Parses a JSON string. ``` #parsejson (string) ``` ``` {{#parsejson '[1, 2, 3]'}} ``` ``` [1 2 3] ``` ### Array Functions #### Concatenate - concat Concatenates one or more arrays together. ``` #concat (array) ... (array) ``` ``` // array1 = ['1', '3', '5']; // array2 = ['2', '4', '6'] {{#concat array1 array2 }} ``` ``` ['1', '3', '5', '2', '4', '6'] ``` #### Length - length Returns the length of the specified array. ``` #length (array) ``` ``` // array = ['one', 'two', 'three'] {{#length array}} ``` ``` 3 ``` #### Distinct - distinct Removes duplicates from an array, keeping the order the same. The optional key_template argument is a Handlebars expression that defines the key for each object in the array. ``` #distinct (array) (string) ``` ``` // array = [1, 2, 1, 3] {{#distinct array}} ``` ``` [1, 2, 3] ``` #### Sort - sort Sorts an array. The optional key_template argument is a Handlebars expression that defines the key for each object in the array. ``` #sort (array) (string) ``` ``` // array = [5, 4, 1, 3, 2] {{#sort array}} ``` ``` [1, 2, 3, 4, 5] ``` #### Includes - includes Returns True if the array contains the specified value. The optional key_template argument is a Handlebars expression that defines the comparison value if the array contains objects. ``` #includes (array) (object) (string) ``` ``` // array = [1, 2, 3] {{#includes array 5}} ``` ``` False ``` #### Map - map Returns an array by applying a Handlebars expression to each object in the source array. ``` #map (array) (string) ``` ``` // array = [{id: 1, value: 2},{id: 3, value: 4},{id: 5, value: 6}] {{#map array '#add value 5'}} ``` ``` [7, 9, 11] ``` #### Filter - filter Filters a source array by items found in a second array. The optional key_template arguments are Handlebars expressions that are applied to each object in the corresponding arrays. ``` #filter (array) (array) (string) (string) ``` ``` // array1 = [1, 2, 3] // array2 = [2, 3, 4] {{#filter array1 array2}} ``` ``` [2, 3] ``` #### Except - except Filters a source array by items not found in a second array. The optional key_template arguments are Handlebars expressions that are applied to each object in the corresponding arrays. ``` #except (array) (array) (string) (string) ``` ``` // array1 = [1, 2, 3] // array2 = [2, 3, 4] {{#except array1 array2}} ``` ``` [1] ``` ### Control Logic #### If - if Renders the enclosed block only if the condition is true. Supports additional 'else if' and 'else' blocks. ``` #if (boolean) ``` ``` {{#if (eq 1 2)}} foo {{else if (eq 'this' 'that')}} bar {{else}} foobar {{~/if}} ``` ``` foobar ``` #### List - list Renders a collection of objects with a delimiter. Within a list block, the outer context can be accessed via the 'root' object. ``` #list (object[]) [string] ``` ``` // array = ['reuse', 'recycle', 'pollute'] // prefix = 're' {{#list array ','}} {{#if (contains this root.prefix)}} '{{this}}' {{~/if}} {{/list}} ``` ``` 'reuse','recycle' ``` ### Conditions #### Not - not Negates the value ``` #not (boolean) ``` ``` {{#not True}} ``` ``` False ``` #### Equals - eq Returns True if two values are equal. ``` #eq (object) (object) ``` ``` {{#eq (subtract 3 2) 1}} ``` ``` True ``` #### NotEqual - ne Returns True if two values are not equal. ``` #ne (object) (object) ``` ``` {{#ne (add 3 2) 1}} ``` ``` True ``` #### LessThan - lt Returns True if the first value is less than the second value. ``` #lt (number) (number) ``` ``` {{#lt 2 3}} ``` ``` True ``` #### GreaterThan - gt Returns True if the first value is greater than the second value. ``` #gt (number) (number) ``` ``` {{#gt 2 3}} ``` ``` False ``` #### LessThanOrEqual - lte Returns True if the first value is less than or equal to the second value. ``` lte (number) (number) ``` ``` {{#lte 2 3}} ``` ``` True ``` #### GreaterThanOrEqual - gte Returns True if the first value is greater than or equal to the second value. ``` #gte (number) (number) ``` ``` {{#gte 2 3}} ``` ``` False ``` #### And - and Performs an AND operation on one or more boolean values. ``` #and (boolean) ... (boolean) ``` ``` {{#and True False}} ``` ``` False ``` #### Or - or Performs an OR operation on one or more boolean values. ``` #or (boolean) ... (boolean) ``` ``` {{#or True False}} ``` ``` True ```