Skip to main content
Use "type": "boolean" for true/false values.

Example

{
  "type": "object",
  "properties": {
    "is_active": { "type": "boolean" },
    "email_verified": { "type": "boolean" }
  },
  "required": ["is_active", "email_verified"],
  "additionalProperties": false
}
from pydantic import BaseModel, ConfigDict

class Payload(BaseModel):
    model_config = ConfigDict(extra="forbid")

    is_active: bool
    email_verified: bool
import { z } from "zod";

const payloadSchema = z
  .object({
    is_active: z.boolean(),
    email_verified: z.boolean(),
  })
  .strict();
Values must be the literals true or false, not quoted strings (“true” is rejected). Truthy integers like 1 and 0 are not accepted. Booleans are best for explicit flags. If you need multiple states, use a string enum instead.