Taxi StdLib

Taxi ships with a collections of functions for basic operations on data.

These operations are performed locally on data received from services - it does not instruct remote services to perform these changes.

Taxi does not provide implementations of these functions, that’s left to runtimes, such as Orbital.

Strings

A collection of functions for manipulating strings

applyFormat

taxi.stdlib.applyFormat

declare extension function applyFormat(input: Any, format: String):String

Applies a format string to the input value using Java Formatter conventions.

Accepts any value (string, number, date, etc.) as input. The format string controls width, padding, precision, and alignment.

// Zero-pad an integer to 6 digits
find { order: Order } as {
   paddedId: order.id.applyFormat('%06d')
}

Examples

Formats an integer with zero-padding using %05d.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

Left-justifies a string in a 10-character wide field using %-10s.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

concat

taxi.stdlib.concat

declare function concat(Any...):String

Joins all provided values into a single string, in the order they are passed. Null values are omitted.

find { person: Person } as {
   fullName: String = concat(person.firstName, ' ', person.lastName)
}

Examples

Concatenates multiple string values into a single string.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

containsPattern

taxi.stdlib.containsPattern

declare extension function containsPattern(source: String, regex: String): Boolean

Returns true if any part of the source string matches the provided regular expression.

Uses partial matching — the regex does not need to match the entire string. Use ^ and $ anchors for full-string matching.

// Partial match — returns true if the string contains the pattern anywhere
find {
   startsWithHe: Boolean = "hello".containsPattern("^he")
   containsEll: Boolean = "hello".containsPattern("ell")
}

Examples

Demonstrates partial matching: anchor patterns, substring patterns, and non-matching patterns.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

containsString

taxi.stdlib.containsString

declare extension function containsString(source:String, valueToSearchFor:String):Boolean

Returns true if source contains valueToSearchFor as a substring. The match is case-sensitive.

// Check if a description mentions a keyword
find {
   mentionsDiscount: Boolean = Description.containsString("discount")
}

Examples

Checks for a case-sensitive substring match.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

endsWith

taxi.stdlib.endsWith

declare extension function endsWith(source: String, valueToSearchFor:String):Boolean

Returns true if source ends with the specified suffix. The match is case-sensitive.

// Check if a filename has a specific extension
find {
   isCsv: Boolean = FileName.endsWith(".csv")
}

Examples

Checks whether a string ends with a given suffix, case-sensitively.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

indexOf

taxi.stdlib.indexOf

declare extension function indexOf(source:String, valueToSearchFor:String):Int

Returns the zero-based index of valueToSearchFor within source, or -1 if not found.

find { path: FilePath } as {
   dotPosition: Int = path.value.indexOf('.')
}

Examples

Returns the index of a substring within a string, or -1 if not found.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

left

taxi.stdlib.left

declare extension function left(source:String, count:Int):String

Returns the leftmost count characters from a string.

find { account: Account } as {
   prefix: String = account.code.left(3)
}

Examples

Extracts the first N characters from a string.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

length

taxi.stdlib.length

declare extension function length(String):Int

Returns the number of characters in the string.

find { message: Message } as {
   charCount: Int = message.body.length()
}

Examples

Returns the character count of a string.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

lowerCase

taxi.stdlib.lowerCase

declare extension function lowerCase(String):String

Converts all characters in the string to lower case.

find { product: Product } as {
   lowerName: String = product.name.lowerCase()
}

Examples

Converts a string to lower case.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

matches

taxi.stdlib.matches

declare extension function matches(source: String, regex: String): Boolean

Returns true if the entire source string matches the provided regular expression.

Uses full-string matching — the pattern must match the entire string, not just a part of it. Use containsPattern for partial (substring) matching.

find { account: Account } as {
   isValidCode: Boolean = account.code.matches('^[A-Z]{3}-\d{4}$')
}

Examples

Returns true only when the full string matches the regex pattern.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

mid

taxi.stdlib.mid

declare extension function mid(source: String, startIndex: Int, endIndex: Int):String

Returns the middle of a string, starting at startIndex (inclusive) and ending just before endIndex (exclusive).

Uses zero-based indexing, identical to String.substring() in Java/Kotlin.

find { order: Order } as {
   yearPart: String = order.isoDate.mid(0, 4)
}

Examples

Extracts a substring using a zero-based start index (inclusive) and end index (exclusive).

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

padEnd

taxi.stdlib.padEnd

declare extension function padEnd(input: String, length: Int, padWith: String):String

Pads the string to the specified total length by appending padWith characters at the end.

padWith should be a single character — if multiple characters are passed, only the first is used.

find { product: Product } as {
   paddedCode: String = product.code.padEnd(10, ' ')
}

Examples

Pads a string to the target length by appending characters on the right.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

padStart

taxi.stdlib.padStart

declare extension function padStart(input: String, length: Int, padWith: String):String

Pads the string to the specified total length by prepending padWith characters at the start.

padWith should be a single character — if multiple characters are passed, only the first is used.

find { order: Order } as {
   paddedId: String = order.id.padStart(8, '0')
}

Examples

Zero-pads a short string to the target length from the left.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

replace

taxi.stdlib.replace

declare extension function replace(source: String, searchValue:String, replacement: String):String

Replaces all occurrences of searchValue in source with replacement, returning a new string.

find { order: Order } as {
   cleanRef: String = order.reference.replace('-', '_')
}

Examples

Replaces all occurrences of a substring with a new value.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

taxi.stdlib.right

declare extension function right(source:String, count:Int):String

Returns the rightmost count characters from a string.

find { account: Account } as {
   suffix: String = account.code.right(4)
}

Examples

Extracts the last N characters from a string.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

startsWith

taxi.stdlib.startsWith

declare extension function startsWith(source: String, valueToSearchFor:String):Boolean

Returns true if source begins with the specified prefix. The match is case-sensitive.

find { files: File[] } as {
   tempFiles: File[] = files.filter((File) -> FileName.startsWith('tmp_'))
}

Examples

Returns true when the string begins with the specified prefix, case-sensitively.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

trim

taxi.stdlib.trim

declare extension function trim(String):String

Removes leading and trailing whitespace from a string.

find { order: Order } as {
   cleanRef: String = order.referenceCode.trim()
}

Examples

Strips leading and trailing whitespace from a string.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

upperCase

taxi.stdlib.upperCase

declare extension function upperCase(String):String

Converts all characters in the string to upper case.

find { product: Product } as {
   upperName: String = product.name.upperCase()
}

Examples

Converts a string to upper case.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

Collections

A collection of functions for operating on collections

all

taxi.stdlib.all

declare extension function <T> all(collection: T[], predicate: (T) -> Boolean): Boolean

Returns true if every item in the collection satisfies the predicate, or false if any item does not.

Returns true for an empty collection (vacuous truth).

// Check if every task in a sprint is complete
find { sprint: Sprint } as {
   allDone: Boolean = sprint.tasks.all((task) -> task.isComplete)
}

Examples

Returns true when every item in the collection satisfies the predicate.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

Returns false when at least one item does not satisfy the predicate.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

allOf

taxi.stdlib.allOf

declare function allOf(values:Boolean...): Boolean

Returns true only if all provided boolean values are true. Equivalent to logical AND.

This function ensures that every condition in a set must be satisfied.

// Check if a user can purchase a premium item
type CanPurchasePremium inherits Boolean by allOf(IsActive, HasSufficientFunds, IsVerified)

Examples

This example demonstrates how to use allOf() to verify if a user meets all required criteria for premium access.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

any

taxi.stdlib.any

declare extension function <T> any(collection: T[], predicate: (T) -> Boolean): Boolean

Returns true if at least one item in the collection satisfies the predicate, or false if none do.

Returns false for an empty collection.

// Check whether any order in a batch is flagged
find { batch: OrderBatch } as {
   needsAttention: Boolean = batch.orders.any((order) -> order.isFlagged)
}

Examples

Returns true when at least one item satisfies the predicate.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

anyOf

taxi.stdlib.anyOf

declare function anyOf(values:Boolean...): Boolean

Returns true if at least one of the provided boolean values is true. Equivalent to logical OR.

This function evaluates multiple conditions and returns true if any of them are true.

// Check if a user has any account verification
type IsVerified inherits Boolean by anyOf(HasEmailVerification, HasPhoneVerification, HasIdVerification)

Examples

Returns true when at least one of the provided boolean conditions is true. Define a computed type in the schema using anyOf for reuse across queries.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

append

taxi.stdlib.append

declare extension function <T> append(array1: T[], array2: T[]):T[]

Returns a new collection containing the elements of the first array followed by the elements of the second array.

Neither input array is modified.

find { cart: ShoppingCart } as {
   allItems: cart.regularItems.append(cart.saleItems)
}

Examples

Concatenates two arrays, returning a new array with elements of the first followed by elements of the second.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

collectAllInstances

taxi.stdlib.collectAllInstances

declare extension function <T> collectAllInstances(collection: lang.taxi.Type<T>): T

Collects and merges all instances of a type from the current data context, bypassing ambiguity checks.

Without this function, a search for T[] will return null when multiple separate collections of T exist (the result is considered ambiguous). collectAllInstances disables that check and concatenates all found instances into a single collection.

// Merge homeAddresses and workAddresses into one list
find { person: Person } as {
   allAddresses: collectAllInstances(Address)
}

Examples

Merges all Address collections on a Person into a single flat list, even though they live in separate fields.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

contains

taxi.stdlib.contains

declare extension function <T> contains(collection: T[], searchTarget:T): Boolean

Returns true if the collection contains the specified search target element.

This function checks whether a given element exists within an array or collection.

// Check if a user's roles include admin privileges
find { user: User } as {
   hasAdminAccess: user.roles.contains("ADMIN")
}

Examples

Checks whether a collection contains a specific element using type-based access.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

containsAll

taxi.stdlib.containsAll

declare extension function <T> containsAll(collection: T[], searchTarget:T[]): Boolean

Returns true if the collection contains every element in the search targets array.

Returns true when searchTargets is empty (an empty set is a subset of every set).

// Check whether a product has all required tags
find {
   hasCertified: Boolean = ProductTag[].containsAll(['certified', 'in-stock'])
}

Known limitation: When the collection uses a semantic type (e.g. ProductTag inherits String), passing string literals as searchTargets always returns false due to a type comparison bug. See problems/containsAll.md. Use a String[] collection as a workaround.

Examples

Returns true when the collection contains all specified search values, false if any are missing.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

containsAny

taxi.stdlib.containsAny

declare extension function <T> containsAny(collection: T[], searchTarget:T[]): Boolean

Returns true if the collection contains at least one of the specified search targets.

Returns true when searchTargets is empty (symmetrical with containsAll).

// Check whether a product has any of a set of tags
find {
   isRelevant: Boolean = ProductTag[].containsAny(['sale', 'featured', 'new'])
}

Known limitation: When the collection uses a semantic type (e.g. ProductTag inherits String), passing string literals as searchTargets always returns false due to a type comparison bug. See problems/containsAny.md. Use a String[] collection as a workaround.

Examples

Returns true when the collection contains at least one of the search values, false when none match.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

exactlyOne

taxi.stdlib.exactlyOne

declare extension function <T> exactlyOne(collection:T[]):T

Returns the only item from the provided collection, or throws an error if there isn’t exactly one item in the collection.

This function is useful when you expect a collection to contain precisely one element and want to retrieve it.

// Get the single active session for a user
find { user: User } as {
   currentSession: user.sessions.filter((session) -> session.isActive).exactlyOne()
}

Examples

This example demonstrates how to use exactlyOne() to retrieve the single active session for a user.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

filter

taxi.stdlib.filter

declare extension function <T> filter(collection:T[], callback: (T) -> Boolean):T[]

Returns a new collection containing only the members of the original collection that match the provided predicate.

This function is used to select a subset of elements from a collection based on a condition.

find { store: Store } as {
   allProducts: store.products // all products
   inStockProducts: store.products.filter((product) -> product.stockLevel > 0)
   affordableProducts: store.products.filter((product) -> product.price < 50.00)
}

Examples

Filters a collection by predicate, returning only matching elements. Uses type-based lambda for clean, semantic access.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

filterEach

taxi.stdlib.filterEach

declare extension function <T> filterEach(item: T, callback: (T) -> Boolean):T?

Evaluates the predicate against the provided item, returning the item if the predicate returns true, or null otherwise.

This function is intended for use in filtering streams, where null values are automatically excluded.

// Filter individual items in a pipeline
find { items: Item[] } as {
   processedItems: items.map((item) -> filterEach(item, (i) -> i.status == "READY"))
}

first

taxi.stdlib.first

declare extension function <T> first(collection: T[]):T

Returns the first item within the collection. Throws an error if the collection is empty.

This function retrieves the first element in an ordered collection.

// Get the most recent transaction from a sorted list
find { account: Account } as {
   latestTransaction: account.transactions.first()
}

Examples

This example demonstrates how to use first() to retrieve the most recent transaction for an account.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

getAtIndex

taxi.stdlib.getAtIndex

declare extension function <T> getAtIndex(collection: T[], index: Int):T

Returns the item at the provided index in the collection. Throws an error if the index is out of bounds.

This function retrieves an element at a specific position in a collection, with zero-based indexing.

// Get the second item in a list
find { playlist: Playlist } as {
   secondSong: playlist.songs.getAtIndex(1) // Note: index starts at 0
}

Examples

Retrieves a song from a playlist by its zero-based index position.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

ifEmpty

taxi.stdlib.ifEmpty

declare extension function <T> ifEmpty(source:T[], defaultValue:T[]): T[]

Returns the source array if it is non-empty, otherwise returns the provided default array.

find { order: Order } as {
   tags: order.tags.ifEmpty(['untagged'])
}

Examples

Returns the default array when the source is empty, or the source array when it has elements.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

indexOfItem

taxi.stdlib.indexOfItem

declare extension function <T> indexOfItem(collection:T[], searchItem: T):Int

Returns the zero-based index of an item within a collection, or -1 if the item was not found.

find { playlist: Playlist } as {
   songPosition: Int = playlist.tracks.indexOfItem('Bohemian Rhapsody')
}

Examples

Returns the index of an item in the collection, or -1 if not found.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

intersection

taxi.stdlib.intersection

declare extension function <T> intersection(collectionA: T[], collectionB: T[]):T[]

Returns a new collection containing only the elements that are present in both of the provided collections.

This function identifies common elements between two collections.

// Find common tags between two products
find { productA: Product, productB: Product } as {
   commonTags: intersection(productA.tags, productB.tags)
}

Examples

Returns only elements present in both collections, identified by value equality.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

isNullOrEmpty

taxi.stdlib.isNullOrEmpty

declare extension function <T> isNullOrEmpty(collection:T[]):Boolean

Returns true if the provided collection is either null or contains zero elements.

find { order: Order } as {
   hasNoItems: Boolean = order.items.isNullOrEmpty()
}

Examples

Returns true for an empty collection, false when the collection has elements.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

joinToString

taxi.stdlib.joinToString

declare extension function <T> joinToString(values:T[], separator: String = ",", prefix: String? = null, postfix: String? = null): String

Creates a string from all the elements separated using separator and using the given prefix and postfix if supplied. Null values are omitted.

find { order: Order } as {
   tagList: String = order.tags.joinToString(', ')
}

Examples

Joins array elements into a single string, with optional separator, prefix, and postfix.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

last

taxi.stdlib.last

declare extension function <T> last(collection: T[]):T

Returns the last item within the collection. Throws an error if the collection is empty.

This function retrieves the final element in an ordered collection.

// Get the oldest transaction from a date-sorted list
find { account: Account } as {
   oldestTransaction: account.transactions.last()
}

Examples

This example demonstrates how to use last() to retrieve the oldest transaction for an account.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

listOf

taxi.stdlib.listOf

declare function <T> listOf(values:T...):T[]

Creates and returns an array containing all the provided values.

This function is useful for creating collections inline without having to define them separately.

// Create a list of allowed status values
find { order: Order } as {
   isValidStatus: listOf('PENDING', 'PROCESSING', 'SHIPPED', 'DELIVERED').contains(order.status)
}

Examples

Creates an inline collection to check if an order status is one of the valid values.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

none

taxi.stdlib.none

declare extension function <T> none(collection: T[], predicate: (T) -> Boolean): Boolean

Returns true if none of the items in the collection satisfy the predicate.

Returns true for an empty collection (vacuous truth).

// Check that no task is overdue
find { sprint: Sprint } as {
   noOverdue: Boolean = sprint.tasks.none((task) -> task.isOverdue)
}

Examples

Returns true when no item in the collection satisfies the predicate.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

noneOf

taxi.stdlib.noneOf

declare function noneOf(values:Boolean...): Boolean

Returns true only if all provided boolean values are false. Equivalent to logical NOR.

This function is useful for checking if none of multiple conditions apply.

// Check if a user has no permissions
type NoPermissions inherits Boolean by noneOf(IsAdmin, IsEditor, IsViewer)

Examples

Returns true when all provided boolean conditions are false. Uses type-based access to combine semantic boolean types.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

orEmpty

taxi.stdlib.orEmpty

declare extension function <T> orEmpty(source:T[]): T[]

Returns the source array unchanged if it is non-null, or an empty array if it is null.

Useful for safely chaining collection operations on potentially-null fields.

find { user: User } as {
   roles: user.roles.orEmpty().joinToString(', ')
}

Examples

Returns the collection unchanged when non-null. Use .orEmpty() to safely chain operations on nullable arrays.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

single

taxi.stdlib.single

declare extension function <T> single(collection:T[], callback: (T) -> Boolean):T

Returns the first item from a collection that matches the provided predicate. Throws an error if no matching item is found.

This function is useful when you need to find a specific element in a collection based on a condition.

// Find a product by its SKU code
find { inventory: Inventory } as {
   appleMacbook: inventory.products.single((product) -> product.sku == "MB-PRO-2023")
}

Examples

Finds the single product matching the given SKU. Throws if no match or more than one match is found.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

singleBy

taxi.stdlib.singleBy

declare extension function <T,A> singleBy(collection:T[], groupingFunction: (T) -> A, searchValue: A):T

Returns the item from a collection where the value returned by the grouping function matches the search value.

Similar to single(), but results are first grouped by the selector function, and these results are cached to improve future performance when querying the same collection multiple times.

// Find a product by its SKU code using a cached search
find { inventory: Inventory } as {
   appleMacbook: inventory.products.singleBy((product) -> product.sku, "MB-PRO-2023")
}

Examples

Looks up products by SKU using a cached index. Faster than single() when querying the same collection multiple times.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

size

taxi.stdlib.size

declare extension function <T> size(collection:T[]):Int

Returns the number of elements in the collection.

find { orders: Order[] } as {
   orderCount: Int = orders.size()
}

Examples

Returns the number of elements in the collection.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

Dates

Mess about with time. Flux capacitor not included

addDays

taxi.stdlib.dates.addDays

declare function <T> addDays(T, Int):T

Adds the specified number of days to a date, datetime, or instant. Use a negative value to subtract days.

// Calculate an expiry date 90 days from today
find {
   @Format("yyyy-MM-dd")
   expiresOn: Date = addDays(Date, 90)
}

Examples

Adds days to a date — positive to advance, negative to go back.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

addMinutes

taxi.stdlib.dates.addMinutes

declare function <T> addMinutes(T, Int):T

Adds the specified number of minutes to a datetime or instant. Use a negative value to subtract minutes.

// Schedule a meeting 30 minutes from the event start
find {
   meetingEnd: DateTime = addMinutes(DateTime, 30)
}

Examples

Adds minutes to a datetime — positive to advance, negative to go back.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

addSeconds

taxi.stdlib.dates.addSeconds

declare function <T> addSeconds(T, Int):T

Adds the specified number of seconds to a datetime or instant. Use a negative value to subtract seconds.

// Expire a token 3600 seconds (1 hour) from now
find {
   expiresAt: Instant = addSeconds(Instant, 3600)
}

Examples

Adds seconds to an instant — positive to advance, negative to go back.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

currentDate

taxi.stdlib.dates.currentDate

declare function currentDate():Date

Returns the current local date (no time component).

find {
   @Format("yyyy-MM-dd")
   today: Date = currentDate()
}

currentDateTime

taxi.stdlib.dates.currentDateTime

declare function currentDateTime():DateTime

Returns the current local date and time.

find {
   @Format("yyyy-MM-dd HH:mm:ss")
   now: DateTime = currentDateTime()
}

currentTime

taxi.stdlib.dates.currentTime

declare function currentTime():Time

Returns the current local time (no date component).

find {
   @Format("HH:mm:ss")
   timeNow: Time = currentTime()
}

now

taxi.stdlib.dates.now

declare function now():Instant

Returns the current UTC instant.

The output changes every time the function is called. Use @Format to control how the instant is serialised in query output.

// Stamp the current time on a record
find {
   @Format("yyyy-MM-dd'T'HH:mm:ssXXX")
   processedAt: Instant = now()
}

parseDate

taxi.stdlib.dates.parseDate

declare function <T> parseDate(String):T

Parses a string into a date, datetime, or instant value. The target type determines which parsing rules are applied.

Supported target types are Date, DateTime, and Instant. Use @Format on the result field to control the output serialisation format.

// Parse an ISO date string into a Date value
find {
   @Format("yyyy-MM-dd")
   eventDate: Date = parseDate("2024-06-15")
}

Examples

Parses ISO date and datetime strings into their respective Taxi date types.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

Math

Numbers ‘n’ such. Maths for the brits.

average

taxi.stdlib.average

declare extension function average(values: Any[]):Decimal

Returns the arithmetic mean of a collection of numeric values.

All values in the collection must be of the same numeric primitive type (Int, Decimal, etc.). Returns null if the collection is empty or contains non-numeric values.

find { order: Order } as {
   averageItemPrice: Decimal = order.items.map((Item) -> Item::price).average()
}

Examples

Computes the average score from a collection of items.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

max

taxi.stdlib.max

declare extension function <T,A> max(collection: T[], callback: (T) -> A):A

Returns the maximum value in the collection, computed by applying the selector function to each element.

find { products: Product[] } as {
   mostExpensive: Price = products.max((Product) -> Price)
}

Examples

Returns the maximum price from a collection of products.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

min

taxi.stdlib.min

declare extension function <T,A> min(collection: T[], callback: (T) -> A):A

Returns the minimum value in the collection, computed by applying the selector function to each element.

find { products: Product[] } as {
   cheapest: Price = products.min((Product) -> Price)
}

Examples

Returns the minimum price from a collection of products.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

round

taxi.stdlib.round

declare extension function round(value: Decimal, precision: Int = 0): Decimal

Rounds a decimal value to the specified number of decimal places.

precision defaults to 0 (round to nearest integer).

find { measurement: Measurement } as {
   rounded: Decimal = measurement.value.round(2)
}

Examples

Rounds a decimal to the specified number of decimal places.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

sum

taxi.stdlib.sum

declare extension function <T,A> sum(collection: T[], callback: (T) -> A):A

Returns the sum of values in the collection, computed by applying the selector function to each element.

find { order: Order } as {
   total: Price = order.items.sum((Item) -> Price)
}

Examples

Sums a numeric field across all elements of a collection.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

Objects

Utilities for dealing with equality, etc

emptyInstance

taxi.stdlib.emptyInstance

declare extension function <A> emptyInstance(instanceType:lang.taxi.Type<A>): A

Returns an instance of the requested type with all fields set to their empty state: scalars are null, collections are [], and nested objects are recursively emptied.

// Create a blank template of a type
find {
   blank: MyModel = emptyInstance(MyModel)
}

Examples

Creates an empty instance of a model: scalars are null and collections are empty arrays.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

equals

taxi.stdlib.equals

declare extension function <A,B> equals(a:A, b:B): Boolean

Returns true if two values are equal. Equality is checked by value and type — values of different semantic types are not equal even if their underlying values match.

find {
   match: Boolean = OrderStatus.equals("PENDING")
}

Examples

Compares two string values — matching pair returns true, non-matching returns false.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

Enums

Utilities for enums

enumForName

taxi.stdlib.enumForName

declare extension function <T> enumForName(enumType: lang.taxi.Type<T>, enumName: String): T

Returns the enum member matching the provided value string. Throws if no match is found.

// Look up an enum member by its string value
find {
   status: OrderStatus = enumForName(OrderStatus, "PENDING")
}

Examples

Looks up an enum member by its string value and returns it as a typed enum.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

hasEnumNamed

taxi.stdlib.hasEnumNamed

declare extension function <T> hasEnumNamed(enumType: lang.taxi.Type<T>, enumName: String): Boolean

Returns true if the enum has an explicitly declared member matching the provided name.

Ignores default entries — an enum with a default value will return false for a name that is only matched by the default, not by an explicit declaration.

find {
   valid: Boolean = hasEnumNamed(OrderStatus, "PENDING")
}

Examples

Returns true for a declared enum member name, false for a name not in the enum.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

Aggregations

Functions for aggregating data within transformations.

sumOver

vyne.aggregations.sumOver

declare query function sumOver(Any...):Decimal

A Vyne-specific aggregate function used in analytical queries to compute a running or grouped sum.

Used in sumOver window-style queries where values are aggregated across a result set.

find { orders: Order[] } as {
   totalRevenue: Decimal = sumOver(Amount)
}

Functional

Functions that are functionally functions. Funky

fold

taxi.stdlib.fold

declare extension function <T,A> fold(collection: T[], initial: A, callback: (T,A) -> A):A

Iterates over a collection, combining elements with an accumulator to produce a single result.

Unlike reduce, fold starts with an explicit initial value as the accumulator.

// Compute a weighted sum
model Entry {
   weight: Weight inherits Int
   score: Score inherits Int
}
type WeightedTotal by (Entry[]) -> Entry[].fold(0, (Entry, Int) -> Int + (Weight * Score))

map

taxi.stdlib.map

declare extension function <T,A> map(collection: T[], callback: (T) -> A):A[]

Applies a transformation function to every element in a collection, returning a new array of the results.

If the callback is a type expression, each element is converted to that type:

// Convert Person[] to Name[]
Person[].map((Person) -> Name)

If the callback is any other expression, it is evaluated against each element:

// Return an array of uppercased titles
Film[].map((Title) -> Title.upperCase())

Examples

Extracts a field from each object in a collection, returning a typed array.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

reduce

taxi.stdlib.reduce

declare extension function <T,A> reduce(collection: T[], callback: (T,A) -> A):A

Reduces a collection to a single value by applying a combining function to each element and the accumulated result.

Unlike fold, there is no initial value — the first element of the collection is used as the starting accumulator.

// Sum a list of integers
find {
   total: Int = numbers.reduce((Int, Int) -> Int + Int)
}

Transformations

Functions for converting between types

convert

taxi.stdlib.convert

declare extension function <T> convert(source: Any, targetType: lang.taxi.Type<T>): T

Converts a source value to the target type using only the data already available — no service calls are made.

This is faster than a full projection (source as TargetType), but less powerful: only the fields present in the source are mapped. Missing fields are not discovered from services.

// Convert an Order to a Receipt using only the Order's own fields
find {
   receipt: Receipt = Order.convert(Receipt)
}

Examples

Converts an Order to a Receipt model using only the fields present in the source, without calling any services.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

toRawType

taxi.stdlib.toRawType

declare extension function toRawType(source: Any):Any

Removes the semantic typing from a scalar value, returning it typed as its raw primitive.

Useful when you need to compare values by their raw content while ignoring their semantic type.

  • For a scalar value: strips the semantic type, returning the underlying primitive.
  • For an array of scalars: strips the semantic type from each element.

Not supported on objects or arrays of objects.

find { order: Order } as {
   rawId: String = order.id.toRawType()
}

Examples

Strips the semantic type from a typed scalar, returning the raw primitive value.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

Parsing

Functions for converting between types

parseJson

taxi.stdlib.parseJson

declare extension function <T> parseJson(source: String, type: Type<T>):T

Parses a JSON string into the specified type.

This is useful when a field contains a JSON payload encoded as a string (e.g., from a message queue or API response), and you need to deserialize it into a structured type.

Computed fields and functions on the target type are evaluated after parsing.

model Event {
   name : String
   payload : String
   parsed : Payload = parseJson(this.payload, Payload)
}

Examples

Parses a JSON string embedded in a model field into a structured type.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed

Errors

Functions for creating and handling errors

throw

taxi.stdlib.throw

declare function throw(error:Any):Nothing

Throws an error, halting execution. Useful for enforcing invariants inline.

find { order: Order } as {
   status: OrderStatus = when {
      OrderStatus == 'INVALID' -> throw('Order status is invalid')
      else -> OrderStatus
   }
}
Next
Welcome to Taxi