BooleanSchema
Validates booleans. Truthy values that are not booleans, such as 1 or
"true", are rejected.
local Enabled = v.boolean()
Properties
isOptional
This item is read only and cannot be modified. Read OnlyReflectionBooleanSchema.isOptional: boolean
Always false. Booleans carry no minimum or maximum, since neither
means anything for two values.
access
This item is read only and cannot be modified. Read OnlyReflectionBooleanSchema.access: "readwrite"
Always "readwrite". Chain BooleanSchema:readonly or
BooleanSchema:writeonly to change it.
Functions
_validate
ParsingBooleanSchema:_validate(value: unknown) → Result<boolean>Validates value without throwing.
parse
ParsingBooleanSchema:parse(value: unknown) → booleanValidates value and returns it, throwing on failure.
Errors
| Type | Description |
|---|---|
| "expected ..." | Thrown when `value` fails validation |
optional
WrapperWraps this schema so that nil is also accepted.
default
WrapperWraps this schema so that nil yields fallback instead of failing.
defaultWith
WrapperBooleanSchema:defaultWith(produce: () → boolean--
Builds the value used when parsing nil
) → DefaultSchema<boolean>
Like BooleanSchema:default, but calls produce on every parse instead of
reusing one value. Use it when the fallback is a table, since a single
table would otherwise be shared by every caller and mutable through any
of them.
The produced value is validated each time, so a producer that returns something invalid fails at parse rather than silently passing through.
readonly
WrapperWraps this schema so that a field using it is typed read.
writeonly
WrapperWraps this schema so that a field using it is typed write.