Skip to main content

Predicates

Ready-made predicate factories for Binder. A predicate is a function that receives a candidate instance and returns true or false, optionally followed by extra values. Binder forwards those extra values to your constructor, so a predicate both filters instances and collects the attribute, child, player or part you were going to look up anyway.

The factories live in the Predicates sub-table of the module (and are also reachable as Binder.Predicates.*). Most accept an optional warningName: when it is given, a failing predicate prints a warning formatted with DEFAULT_WARN_FORMAT_STRING (or your own warnFormatString) telling you which instance failed and why. Without a warningName predicates fail silently.

local Binder = require(path.to.Binder)
local Predicates = require(path.to.Predicates).Predicates

-- Bind every Model tagged "Vendor" that has a numeric Price attribute and a
-- ProximityPrompt child; the constructor receives them in that order.
local vendors = Binder.new(function(model: Model, trove, price: number, prompt: ProximityPrompt)
	trove:Connect(prompt.Triggered, function(player)
		print(`{player.Name} paid {price}`)
	end)

	return trove
end, {
	Tags = { "Vendor" },
	ClassNames = { "Model" },
	Predicate = Predicates.Combine {
		Predicates.Attribute("Price", "number", "VendorBinder"),
		Predicates.ChildWhichIsA("ProximityPrompt", "VendorBinder"),
	},
	AutoStart = true,
})

The module table is { DEFAULT_WARN_FORMAT_STRING, doPredicateWarning, Predicates = { ... }, T }, where T is the bundled t type-checking library for use as a TypeValidator.

Credits: type validation is done with t, originally by Osyris. Wally installs it.

Installation and guide: Predicates package page.

Types​

Predicate​

type Predicate = (any) → (
boolean,
...any
)

A function that receives the candidate (normally an Instance) and returns whether it passes, followed by any extra values. Binder passes those extra values to the constructor after the Trove. The first return value must be a real boolean.

TypeValidator​

type TypeValidator = "any" | string | (value: any) → any?

Describes the type an attribute must have, for Attribute and Attributes. Either a typeof name such as "number", "string", "Color3" or "Vector3", the string "any" (accepts any non-nil value), or a function that receives the value and either errors, returns a message, or returns true.

CAUTION

In the current version a function validator is always reported as failing, because the result check treats every return value (including true) as an error. Use a type-name string until this is fixed.

Properties​

DEFAULT_WARN_FORMAT_STRING​

This item is read only and cannot be modified. Read Only
Predicates.DEFAULT_WARN_FORMAT_STRING: string

"[%s] Predicate failed for %s: %s". The string.format pattern used for predicate warnings when no warnFormatString is supplied. The three %s receive the warning name, the instance's full name and the failure message, in that order; a custom format string must accept the same three arguments.

T​

This item is read only and cannot be modified. Read Only
Predicates.T: t

The bundled t runtime type-checking library, re-exported for convenience so you can build validators without installing it separately (for example Predicates.T.numberPositive). See the TypeValidator caution before using function validators with Attribute.

Functions​

doPredicateWarning​

Predicates.doPredicateWarning(
instance: Instance,--

The instance that failed; its full name is included in the warning.

warningName: string?,--

Label for the warning (typically the name of your binder or script). Nil suppresses the warning.

warnFormatString: string?,--

string.format pattern with three %s; defaults to DEFAULT_WARN_FORMAT_STRING.

warning: string--

Why the predicate failed.

) → ()

Prints the standard predicate warning for instance. Does nothing when warningName is nil, which is how every factory in this module stays quiet unless you opt in. Useful when writing your own predicates so they warn in the same format as the built-in ones.

local function HasPrimaryPart(warningName: string?): Predicates.Predicate
	return function(model: Model)
		if not model.PrimaryPart then
			Predicates.doPredicateWarning(model, warningName, nil, "Missing PrimaryPart")
			return false
		end
		return true, model.PrimaryPart
	end
end

Combine​

Predicates.Combine(
predicates: {Predicate}--

Predicates to run, in order.

) → Predicate--

A predicate that passes when every input passes and returns all their extra values.

Runs several predicates in order and passes only if all of them pass. The extra values of every predicate are concatenated in the same order, so a constructor receives the values of the first predicate, then the second, and so on. The first failing predicate short-circuits the rest.

Predicate = Predicates.Combine {
	Predicates.Attribute("Speed", "number", "CarBinder"),
	Predicates.Child("Seat", "VehicleSeat", "CarBinder"),
}
-- constructor(instance, trove, speed: number, seat: VehicleSeat)

Attribute​

Predicates.Attribute(
attribute: string,--

Name of the attribute to read.

typeValidator: TypeValidator?,--

Type the value must have; skipped when nil.

warningName: string?,--

Enables warnings on failure; see doPredicateWarning.

warnFormatString: string?--

Custom warning format; defaults to DEFAULT_WARN_FORMAT_STRING.

) → Predicate--

Passes with the attribute value as its extra value.

Requires the instance to have the attribute attribute and returns its value as the extra value. When typeValidator is given the value must also satisfy it.

CAUTION

The attribute is considered missing when its value is falsy, so a boolean attribute set to false fails this predicate. Use a different representation (for example a number or string) for flags that may be off.

Attributes​

Predicates.Attributes(
attributes: {[string]: TypeValidator},--

Attribute names mapped to the type each must have (use "any" to accept anything).

warningName: string?,--

Enables warnings on failure; see doPredicateWarning.

warnFormatString: string?--

Custom warning format; defaults to DEFAULT_WARN_FORMAT_STRING.

) → Predicate--

Passes with every attribute value as extra values.

Shorthand for Combine over one Attribute predicate per entry of attributes. Every listed attribute must exist and match its validator; all of their values are returned as extra values.

CAUTION

attributes is a dictionary, so the order in which the values are returned follows table iteration order and is not guaranteed. When you need more than one value in a known order, use Combine with explicit Attribute calls instead.

Child​

Predicates.Child(
name: string,--

Name of the child to find.

isA: string?,--

Class name the child must be (or inherit from); skipped when nil.

warningName: string?,--

Enables warnings on failure; see doPredicateWarning.

warnFormatString: string?--

Custom warning format; defaults to DEFAULT_WARN_FORMAT_STRING.

) → Predicate--

Passes with the child instance as its extra value.

Requires a direct child named name (found with FindFirstChild, so it does not wait) and returns it as the extra value. When isA is given the child must also satisfy IsA(isA).

ChildWhichIsA​

Predicates.ChildWhichIsA(
isA: string,--

Class name the child must be or inherit from, e.g. "BasePart".

warningName: string?,--

Enables warnings on failure; see doPredicateWarning.

warnFormatString: string?--

Custom warning format; defaults to DEFAULT_WARN_FORMAT_STRING.

) → Predicate--

Passes with the matching child as its extra value.

Requires a direct child of class isA (via FindFirstChildWhichIsA, so subclasses count) and returns the first one found as the extra value.

Descendant​

Predicates.Descendant(
query: string,--

Selector string passed to QueryDescendants.

warningName: string?,--

Enables warnings on failure; see doPredicateWarning.

warnFormatString: string?--

Custom warning format; defaults to DEFAULT_WARN_FORMAT_STRING.

) → Predicate--

Passes with the first matching descendant as its extra value.

Requires at least one descendant matching the selector query (evaluated with Instance:QueryDescendants) and returns the first match as the extra value.

PrimaryPart​

Predicates.PrimaryPart(
primaryPartPredicate: Predicate?,--

Optional predicate to run on the primary part.

warningName: string?,--

Enables warnings on failure; see doPredicateWarning.

warnFormatString: string?--

Custom warning format; defaults to DEFAULT_WARN_FORMAT_STRING.

) → Predicate--

Passes with the primary part, or the inner predicate's extra values, as extra values.

Requires the instance to be a Model with a PrimaryPart set. Without primaryPartPredicate the primary part is returned as the extra value. With it, the inner predicate is run against the primary part and its extra values are returned instead of the part itself.

-- constructor receives (model, trove, primaryPart)
Predicates.PrimaryPart(nil, "TurretBinder")

-- constructor receives (model, trove, range: number) read from the primary part
Predicates.PrimaryPart(Predicates.Attribute("Range", "number", "TurretBinder"), "TurretBinder")

IsDescendantOf​

Predicates.IsDescendantOf(
ancestor: Instance--

The required ancestor.

) → Predicate--

Passes for descendants of ancestor.

Passes when the instance is a descendant of ancestor. Returns no extra values and never warns. Handy inside ContextGate or Combine when a Binder's own Ancestors filter is not enough.

Humanoid​

Predicates.Humanoid(
warningName: string?,--

Enables warnings on failure; see doPredicateWarning.

warnFormatString: string?--

Custom warning format; defaults to DEFAULT_WARN_FORMAT_STRING.

) → Predicate--

Passes with the Humanoid as its extra value.

Requires a Humanoid child and returns it as the extra value. Equivalent to ChildWhichIsA("Humanoid", ...).

Character​

Predicates.Character(
warningName: string?,--

Enables warnings on failure; see doPredicateWarning.

warnFormatString: string?--

Custom warning format; defaults to DEFAULT_WARN_FORMAT_STRING.

) → Predicate--

Passes with (humanoid, humanoidRootPart) as extra values.

Requires the instance to look like a character: a Humanoid child and a BasePart child named HumanoidRootPart. Returns the Humanoid, then the HumanoidRootPart, as extra values.

Player​

Predicates.Player(
warningName: string?,--

Enables warnings on failure; see doPredicateWarning.

warnFormatString: string?--

Custom warning format; defaults to DEFAULT_WARN_FORMAT_STRING.

) → Predicate--

Passes with the owning Player as its extra value.

Finds the Player an instance belongs to and returns it as the extra value. It checks, in order: the instance itself as a character model, the nearest Model ancestor as a character model, and finally a Player ancestor (for things parented under Players.<Name>, such as items in a Backpack or PlayerGui). Fails when none of those resolves to a player.

ContextGate​

Predicates.ContextGate(
clientPredicate: Predicate,--

Used when RunService:IsServer() is false.

serverPredicate: Predicate--

Used on the server.

) → Predicate--

Delegates to one of the two predicates.

Picks a predicate based on where the code runs: serverPredicate on the server, clientPredicate on the client. The chosen predicate's results (including extra values) are returned unchanged, so a shared Binder module can demand different things on each side.

StudioOnly​

Predicates.StudioOnly(
warningName: string?,--

Enables the "Studio only" warning; see doPredicateWarning.

warnFormatString: string?--

Custom warning format; defaults to DEFAULT_WARN_FORMAT_STRING.

) → Predicate--

Always passes, warning outside Studio.

Warns (when warningName is set) if the code is not running in Studio. Note that it always returns true; it flags an instance that should not exist in a live game without blocking the bind. Wrap it in your own predicate if you need it to actually reject.

Show raw api
{
    "functions": [
        {
            "name": "doPredicateWarning",
            "desc": "Prints the standard predicate warning for `instance`. Does nothing when `warningName` is nil,\nwhich is how every factory in this module stays quiet unless you opt in. Useful when writing\nyour own predicates so they warn in the same format as the built-in ones.\n\n```lua\nlocal function HasPrimaryPart(warningName: string?): Predicates.Predicate\n\treturn function(model: Model)\n\t\tif not model.PrimaryPart then\n\t\t\tPredicates.doPredicateWarning(model, warningName, nil, \"Missing PrimaryPart\")\n\t\t\treturn false\n\t\tend\n\t\treturn true, model.PrimaryPart\n\tend\nend\n```",
            "params": [
                {
                    "name": "instance",
                    "desc": "The instance that failed; its full name is included in the warning.",
                    "lua_type": "Instance"
                },
                {
                    "name": "warningName",
                    "desc": "Label for the warning (typically the name of your binder or script). Nil suppresses the warning.",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "`string.format` pattern with three `%s`; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                },
                {
                    "name": "warning",
                    "desc": "Why the predicate failed.",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 146,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "Combine",
            "desc": "Runs several predicates in order and passes only if all of them pass. The extra values of every\npredicate are concatenated in the same order, so a constructor receives the values of the first\npredicate, then the second, and so on. The first failing predicate short-circuits the rest.\n\n```lua\nPredicate = Predicates.Combine {\n\tPredicates.Attribute(\"Speed\", \"number\", \"CarBinder\"),\n\tPredicates.Child(\"Seat\", \"VehicleSeat\", \"CarBinder\"),\n}\n-- constructor(instance, trove, speed: number, seat: VehicleSeat)\n```",
            "params": [
                {
                    "name": "predicates",
                    "desc": "Predicates to run, in order.",
                    "lua_type": "{ Predicate }"
                }
            ],
            "returns": [
                {
                    "desc": "A predicate that passes when every input passes and returns all their extra values.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 190,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "Attribute",
            "desc": "Requires the instance to have the attribute `attribute` and returns its value as the extra\nvalue. When `typeValidator` is given the value must also satisfy it.\n\n:::caution\nThe attribute is considered missing when its value is falsy, so a boolean attribute set to\n`false` fails this predicate. Use a different representation (for example a number or string)\nfor flags that may be off.\n:::",
            "params": [
                {
                    "name": "attribute",
                    "desc": "Name of the attribute to read.",
                    "lua_type": "string"
                },
                {
                    "name": "typeValidator",
                    "desc": "Type the value must have; skipped when nil.",
                    "lua_type": "TypeValidator?"
                },
                {
                    "name": "warningName",
                    "desc": "Enables warnings on failure; see [doPredicateWarning](#doPredicateWarning).",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "Custom warning format; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "Passes with the attribute value as its extra value.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 228,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "Attributes",
            "desc": "Shorthand for [Combine](#Combine) over one [Attribute](#Attribute) predicate per entry of\n`attributes`. Every listed attribute must exist and match its validator; all of their values are\nreturned as extra values.\n\n:::caution\n`attributes` is a dictionary, so the order in which the values are returned follows table\niteration order and is not guaranteed. When you need more than one value in a known order, use\n[Combine](#Combine) with explicit [Attribute](#Attribute) calls instead.\n:::",
            "params": [
                {
                    "name": "attributes",
                    "desc": "Attribute names mapped to the type each must have (use `\"any\"` to accept anything).",
                    "lua_type": "{ [string]: TypeValidator }"
                },
                {
                    "name": "warningName",
                    "desc": "Enables warnings on failure; see [doPredicateWarning](#doPredicateWarning).",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "Custom warning format; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "Passes with every attribute value as extra values.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 269,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "Child",
            "desc": "Requires a direct child named `name` (found with `FindFirstChild`, so it does not wait) and\nreturns it as the extra value. When `isA` is given the child must also satisfy `IsA(isA)`.",
            "params": [
                {
                    "name": "name",
                    "desc": "Name of the child to find.",
                    "lua_type": "string"
                },
                {
                    "name": "isA",
                    "desc": "Class name the child must be (or inherit from); skipped when nil.",
                    "lua_type": "string?"
                },
                {
                    "name": "warningName",
                    "desc": "Enables warnings on failure; see [doPredicateWarning](#doPredicateWarning).",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "Custom warning format; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "Passes with the child instance as its extra value.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 294,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "ChildWhichIsA",
            "desc": "Requires a direct child of class `isA` (via `FindFirstChildWhichIsA`, so subclasses count) and\nreturns the first one found as the extra value.",
            "params": [
                {
                    "name": "isA",
                    "desc": "Class name the child must be or inherit from, e.g. `\"BasePart\"`.",
                    "lua_type": "string"
                },
                {
                    "name": "warningName",
                    "desc": "Enables warnings on failure; see [doPredicateWarning](#doPredicateWarning).",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "Custom warning format; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "Passes with the matching child as its extra value.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 323,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "Descendant",
            "desc": "Requires at least one descendant matching the selector `query` (evaluated with\n`Instance:QueryDescendants`) and returns the first match as the extra value.",
            "params": [
                {
                    "name": "query",
                    "desc": "Selector string passed to `QueryDescendants`.",
                    "lua_type": "string"
                },
                {
                    "name": "warningName",
                    "desc": "Enables warnings on failure; see [doPredicateWarning](#doPredicateWarning).",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "Custom warning format; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "Passes with the first matching descendant as its extra value.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 347,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "PrimaryPart",
            "desc": "Requires the instance to be a `Model` with a `PrimaryPart` set. Without `primaryPartPredicate`\nthe primary part is returned as the extra value. With it, the inner predicate is run against the\nprimary part and its extra values are returned *instead of* the part itself.\n\n```lua\n-- constructor receives (model, trove, primaryPart)\nPredicates.PrimaryPart(nil, \"TurretBinder\")\n\n-- constructor receives (model, trove, range: number) read from the primary part\nPredicates.PrimaryPart(Predicates.Attribute(\"Range\", \"number\", \"TurretBinder\"), \"TurretBinder\")\n```",
            "params": [
                {
                    "name": "primaryPartPredicate",
                    "desc": "Optional predicate to run on the primary part.",
                    "lua_type": "Predicate?"
                },
                {
                    "name": "warningName",
                    "desc": "Enables warnings on failure; see [doPredicateWarning](#doPredicateWarning).",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "Custom warning format; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "Passes with the primary part, or the inner predicate's extra values, as extra values.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 381,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "IsDescendantOf",
            "desc": "Passes when the instance is a descendant of `ancestor`. Returns no extra values and never\nwarns. Handy inside [ContextGate](#ContextGate) or [Combine](#Combine) when a Binder's own\n`Ancestors` filter is not enough.",
            "params": [
                {
                    "name": "ancestor",
                    "desc": "The required ancestor.",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "Passes for descendants of `ancestor`.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 418,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "Humanoid",
            "desc": "Requires a `Humanoid` child and returns it as the extra value. Equivalent to\n`ChildWhichIsA(\"Humanoid\", ...)`.",
            "params": [
                {
                    "name": "warningName",
                    "desc": "Enables warnings on failure; see [doPredicateWarning](#doPredicateWarning).",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "Custom warning format; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "Passes with the Humanoid as its extra value.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 434,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "Character",
            "desc": "Requires the instance to look like a character: a `Humanoid` child and a `BasePart` child named\n`HumanoidRootPart`. Returns the Humanoid, then the HumanoidRootPart, as extra values.",
            "params": [
                {
                    "name": "warningName",
                    "desc": "Enables warnings on failure; see [doPredicateWarning](#doPredicateWarning).",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "Custom warning format; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "Passes with `(humanoid, humanoidRootPart)` as extra values.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 448,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "Player",
            "desc": "Finds the `Player` an instance belongs to and returns it as the extra value. It checks, in\norder: the instance itself as a character model, the nearest `Model` ancestor as a character\nmodel, and finally a `Player` ancestor (for things parented under `Players.<Name>`, such as\nitems in a Backpack or PlayerGui). Fails when none of those resolves to a player.",
            "params": [
                {
                    "name": "warningName",
                    "desc": "Enables warnings on failure; see [doPredicateWarning](#doPredicateWarning).",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "Custom warning format; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "Passes with the owning Player as its extra value.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 467,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "ContextGate",
            "desc": "Picks a predicate based on where the code runs: `serverPredicate` on the server,\n`clientPredicate` on the client. The chosen predicate's results (including extra values) are\nreturned unchanged, so a shared Binder module can demand different things on each side.",
            "params": [
                {
                    "name": "clientPredicate",
                    "desc": "Used when `RunService:IsServer()` is false.",
                    "lua_type": "Predicate"
                },
                {
                    "name": "serverPredicate",
                    "desc": "Used on the server.",
                    "lua_type": "Predicate"
                }
            ],
            "returns": [
                {
                    "desc": "Delegates to one of the two predicates.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 510,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "StudioOnly",
            "desc": "Warns (when `warningName` is set) if the code is not running in Studio. Note that it **always\nreturns `true`**; it flags an instance that should not exist in a live game without blocking\nthe bind. Wrap it in your own predicate if you need it to actually reject.",
            "params": [
                {
                    "name": "warningName",
                    "desc": "Enables the \"Studio only\" warning; see [doPredicateWarning](#doPredicateWarning).",
                    "lua_type": "string?"
                },
                {
                    "name": "warnFormatString",
                    "desc": "Custom warning format; defaults to [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING).",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "Always passes, warning outside Studio.",
                    "lua_type": "Predicate"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 531,
                "path": "packages/src/Predicates/init.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "DEFAULT_WARN_FORMAT_STRING",
            "desc": "`\"[%s] Predicate failed for %s: %s\"`. The `string.format` pattern used for predicate warnings\nwhen no `warnFormatString` is supplied. The three `%s` receive the warning name, the instance's\nfull name and the failure message, in that order; a custom format string must accept the same\nthree arguments.",
            "lua_type": "string",
            "readonly": true,
            "source": {
                "line": 72,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "T",
            "desc": "The bundled [t](/api/t) runtime type-checking library, re-exported for convenience so you can\nbuild validators without installing it separately (for example `Predicates.T.numberPositive`).\nSee the [TypeValidator](#TypeValidator) caution before using function validators with\n[Attribute](#Attribute).",
            "lua_type": "t",
            "readonly": true,
            "source": {
                "line": 550,
                "path": "packages/src/Predicates/init.luau"
            }
        }
    ],
    "types": [
        {
            "name": "Predicate",
            "desc": "A function that receives the candidate (normally an `Instance`) and returns whether it passes,\nfollowed by any extra values. Binder passes those extra values to the constructor after the\nTrove. The first return value must be a real boolean.",
            "lua_type": "(any) -> (boolean, ...any)",
            "source": {
                "line": 61,
                "path": "packages/src/Predicates/init.luau"
            }
        },
        {
            "name": "TypeValidator",
            "desc": "Describes the type an attribute must have, for [Attribute](#Attribute) and\n[Attributes](#Attributes). Either a `typeof` name such as `\"number\"`, `\"string\"`, `\"Color3\"` or\n`\"Vector3\"`, the string `\"any\"` (accepts any non-nil value), or a function that receives the\nvalue and either errors, returns a message, or returns `true`.\n\n:::caution\nIn the current version a function validator is always reported as failing, because the result\ncheck treats every return value (including `true`) as an error. Use a type-name string until\nthis is fixed.\n:::",
            "lua_type": "\"any\" | string | (value: any) -> any?",
            "source": {
                "line": 89,
                "path": "packages/src/Predicates/init.luau"
            }
        }
    ],
    "name": "Predicates",
    "desc": "Ready-made predicate factories for [Binder](/api/Binder). A predicate is a function that\nreceives a candidate instance and returns `true` or `false`, optionally followed by extra values.\nBinder forwards those extra values to your constructor, so a predicate both *filters* instances\nand *collects* the attribute, child, player or part you were going to look up anyway.\n\nThe factories live in the `Predicates` sub-table of the module (and are also reachable as\n`Binder.Predicates.*`). Most accept an optional `warningName`: when it is given, a failing\npredicate prints a warning formatted with [DEFAULT_WARN_FORMAT_STRING](#DEFAULT_WARN_FORMAT_STRING)\n(or your own `warnFormatString`) telling you which instance failed and why. Without a\n`warningName` predicates fail silently.\n\n```lua\nlocal Binder = require(path.to.Binder)\nlocal Predicates = require(path.to.Predicates).Predicates\n\n-- Bind every Model tagged \"Vendor\" that has a numeric Price attribute and a\n-- ProximityPrompt child; the constructor receives them in that order.\nlocal vendors = Binder.new(function(model: Model, trove, price: number, prompt: ProximityPrompt)\n\ttrove:Connect(prompt.Triggered, function(player)\n\t\tprint(`{player.Name} paid {price}`)\n\tend)\n\n\treturn trove\nend, {\n\tTags = { \"Vendor\" },\n\tClassNames = { \"Model\" },\n\tPredicate = Predicates.Combine {\n\t\tPredicates.Attribute(\"Price\", \"number\", \"VendorBinder\"),\n\t\tPredicates.ChildWhichIsA(\"ProximityPrompt\", \"VendorBinder\"),\n\t},\n\tAutoStart = true,\n})\n```\n\nThe module table is `{ DEFAULT_WARN_FORMAT_STRING, doPredicateWarning, Predicates = { ... },\nT }`, where `T` is the bundled [t](/api/t) type-checking library for use as a\n[TypeValidator](#TypeValidator).\n\n**Credits:** type validation is done with [t](/api/t), originally by [Osyris](https://github.com/osyrisrblx). Wally installs it.\n\nInstallation and guide: [Predicates package page](/docs/packages/predicates).",
    "source": {
        "line": 53,
        "path": "packages/src/Predicates/init.luau"
    }
}