Boolean
Simple boolean validation with optional default.
Chainable Methods
| Method | Description | Example |
|---|---|---|
.default(val) | Fallback boolean | .default(false) |
Example
typescript
import { v, Infer } from 'typyn';
const isActiveSchema = v.boolean().default(false);
const isActive = isActiveSchema.parse(true); // true
const safe = isActiveSchema.safe('yes'); // { success: false, error: { path: '', message: 'Expected boolean' } }
type IsActive = Infer<typeof isActiveSchema>; // booleanError Example: Non-boolean throws "Expected boolean".
Back to Primitives | Next: Literal
Last updated: October 23, 2025.
