T
T is a runtime typecheck for Roblox.
local assertArrayOfNumbers = T.array(T.number)
assertArrayOfNumbers({1, 2, 3}) -- true
Types
CheckerFn
type
CheckerFn =
(
value:
any
)
→
(
boolean
,
string?
)
CheckerFn is a function that takes a value and returns a boolean and an optional error message.
Functions
type
typeof
any
T.
any
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
matches any type except nil
boolean
T.
boolean
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Lua primitive boolean type
thread
T.
thread
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Lua primitive thread type
function
T.
function
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Lua primitive callback type
nil
T.
nil
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Lua primitive none type
string
T.
string
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Lua primitive string type
table
T.
table
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Lua primitive table type
userdata
T.
userdata
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Lua primitive userdata type
number
T.
number
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures value is a number and non-NaN
nan
T.
nan
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures value is NaN
Axes
T.
Axes
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Axes type
BrickColor
T.
BrickColor
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox BrickColor type
CatalogSearchParams
T.
CatalogSearchParams
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox CatalogSearchParams type
CFrame
T.
CFrame
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox CFrame type
Color3
T.
Color3
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Color3 type
ColorSequence
T.
ColorSequence
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox ColorSequence type
ColorSequenceKeypoint
T.
ColorSequenceKeypoint
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox ColorSequenceKeypoint type
DateTime
T.
DateTime
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox DateTime type
DockWidgetPluginGuiInfo
T.
DockWidgetPluginGuiInfo
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox DockWidgetPluginGuiInfo type
Enum
T.
Enum
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Enum type
EnumItem
T.
EnumItem
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox EnumItem type
Enums
T.
Enums
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Enums type
Faces
T.
Faces
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Faces type
FloatCurveKey
T.
FloatCurveKey
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox FloatCurveKey type
Font
T.
Font
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Font type
Instance
T.
Instance
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Instance type
NumberRange
T.
NumberRange
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox NumberRange type
NumberSequence
T.
NumberSequence
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox NumberSequence type
NumberSequenceKeypoint
T.
NumberSequenceKeypoint
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox NumberSequenceKeypoint type
OverlapParams
T.
OverlapParams
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox OverlapParams type
PathWaypoint
T.
PathWaypoint
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox PathWaypoint type
PhysicalProperties
T.
PhysicalProperties
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox PhysicalProperties type
Random
T.
Random
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Random type
Ray
T.
Ray
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Ray type
RaycastParams
T.
RaycastParams
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox RaycastParams type
RaycastResult
T.
RaycastResult
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox RaycastResult type
RBXScriptConnection
T.
RBXScriptConnection
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox RBXScriptConnection type
RBXScriptSignal
T.
RBXScriptSignal
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox RBXScriptSignal type
Rect
T.
Rect
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Rect type
Region3
T.
Region3
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Region3 type
Region3int16
T.
Region3int16
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Region3int16 type
TweenInfo
T.
TweenInfo
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox TweenInfo type
UDim
T.
UDim
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox UDim type
UDim2
T.
UDim2
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox UDim2 type
Vector2
T.
Vector2
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Vector2 type
Vector2int16
T.
Vector2int16
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Vector2int16 type
Vector3
T.
Vector3
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Vector3 type
Vector3int16
T.
Vector3int16
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures Roblox Vector3int16 type
literal
T.
literal
(
...:
...any
--
The literal to use
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is a given literal value
keyOf
T.
keyOf
(
keyTable:
table
--
The table to get keys from
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
Returns a t.union of each key in the table as a t.literal
valueOf
T.
valueOf
(
valueTable:
table
--
The table to get values from
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
Returns a t.union of each value in the table as a t.literal
integer
T.
integer
(
value:
any
--
The value to check against
) →
(
boolean
,
--
True iff the condition is satisfied, false otherwise
string?
)
ensures value is an integer
numberMin
T.
numberMin
(
min:
number
--
The minimum to use
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is a number where min <= value
numberMax
T.
numberMax
(
max:
number
--
The maximum to use
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is a number where value <= max
numberMinExclusive
T.
numberMinExclusive
(
min:
number
--
The minimum to use
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is a number where min < value
numberMaxExclusive
T.
numberMaxExclusive
(
max:
number
--
The maximum to use
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is a number where value < max
numberPositive
ensures value is a number where value > 0
numberNegative
ensures value is a number where value < 0
numberConstrained
T.
numberConstrained
(
min:
number
,
--
The minimum to use
max:
number
--
The maximum to use
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is a number where min <= value <= max
numberConstrainedExclusive
T.
numberConstrainedExclusive
(
min:
number
,
--
The minimum to use
max:
number
--
The maximum to use
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is a number where min < value < max
match
T.
match
(
pattern:
string
--
pattern to check against
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value matches string pattern
optional
T.
optional
(
check:
function
--
The check to use
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is either nil or passes check
tuple
T.
tuple
(
...:
...any
--
The type definition for the tuples
) →
CheckerFn
--
A function that will return true iff the condition is passed
matches given tuple against tuple type definition
keys
T.
keys
(
check:
The
function
to
use
to
check
the
keys
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures all keys in given table pass check
values
T.
values
(
check:
any
--
The function to use to check the values
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures all values in given table pass check
map
T.
map
(
keyCheck:
any
,
--
The function to use to check the keys
valueCheck:
any
--
The function to use to check the values
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is a table and all keys pass keyCheck and all values pass valueCheck
set
T.
set
(
valueCheck:
any
--
The function to use to check the values
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is a table and all keys pass valueCheck and all values are true
array
ensures value is an array and all values of the array match check
strictArray
T.
strictArray
(
...:
...any
--
The check to compare all values with
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is an array of a strict makeup and size
union
T.
union
(
...:
...any
--
The checks to union
) →
CheckerFn
--
A function that will return true iff the condition is passed
creates a union type
some
T.
some
(
) →
(
)
Alias for t.union
intersection
T.
intersection
(
...:
...any
--
The checks to intersect
) →
CheckerFn
--
A function that will return true iff the condition is passed
creates an intersection type
every
T.
every
(
) →
(
)
Alias for t.intersection
interface
T.
interface
(
checkTable:
table
--
The interface definition
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value matches given interface definition
strictInterface
T.
strictInterface
(
checkTable:
table
--
The interface definition
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value matches given interface definition strictly
instanceOf
T.
instanceOf
(
className:
string
,
--
The class name to check for
childTable:
table
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensure value is an Instance and it's ClassName matches the given ClassName
instanceIsA
T.
instanceIsA
(
className:
string
,
--
The class name to check for
childTable:
table
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensure value is an Instance and it's ClassName matches the given ClassName by an IsA comparison
enum
T.
enum
(
enum:
any
--
The enum to check
) →
CheckerFn
--
A function that will return true iff the condition is passed
ensures value is an enum of the correct type
customEnum
T.
customEnum
(
enumSpec:
any
--
The enum to check
) →
CheckerFn
--
A function that will return true if the condition is passed
ensures a value is a custom enum
wrap
T.
wrap
(
callback:
function
,
--
The function to wrap
checkArgs:
function
--
The function to use to check arguments in the assert
) →
CheckerFn
--
A function that first asserts using checkArgs and then calls callback
wraps a callback in an assert with checkArgs
strict
asserts a given check
children
T.
children
(
checkTable:
table
--
The table to check against
) →
CheckerFn
--
A function that checks an instance tree
Takes a table where keys are child names and values are functions to check the children against. Pass an instance tree into the function. If at least one child passes each check, the overall check passes.
Warning! If you pass in a tree with more than one child of the same name, this function will always return false