← Runtime data validation

Data.boolean

luastra/data
Data.boolean(): Schema

Builds a strict boolean schema that accepts only true or false. It does not coerce strings such as "true", numeric flags, or other truthy values.

Before you use it

Add luastra/data to this module's dependencies in luastra.json, then import it with require("luastra/data"). No host capability is required. Define schemas outside render when they are reused.

How it fits

This pure constructor returns an immutable schema synchronously; Data.decode performs the actual validation later.

When to use it

Use Data.boolean for persisted toggles and server fields whose wire contract is genuinely Boolean. Normalize legacy encodings before this boundary or migrate them explicitly rather than relying on implicit coercion.

Parameters

No parameters.

Returns

Schema — an immutable runtime schema that can be composed or passed to Data.decode.

What happens next

An immutable schema ready to compose or pass to Data.decode.

Failures and fixes

Ordinary invalid input is a Data.decode failure, not an exception. Invalid schema options are programmer errors and fail immediately. String bounds count UTF-8 bytes; Data.string has no pattern option in this alpha.

Availability

Public-source alpha API in 0.5.0-alpha; host-independent and synchronous.

Focused example

local Data = require("luastra/data")
local enabled = Data.boolean()

Complete inventory

View all pages in Runtime data validation
← Previous: Data.numberNext: Data.array →