Const
FunctionSchema.parse(function () {}); // ✓ Valid
FunctionSchema.parse(() => {}); // ✓ Valid
FunctionSchema.parse(async () => {}); // ✓ Valid
FunctionSchema.parse(function* () {}); // ✓ Valid
FunctionSchema.parse(Math.max); // ✓ Valid
FunctionSchema.parse('not a function'); // ✗ Throws validation error
FunctionSchema.parse({}); // ✗ Throws validation error
A Zod schema that validates any JavaScript function.
This schema provides function validation capabilities similar to the parseable-only
z.function()
from Zod v3.x, but works with Zod v4's architecture. It validates that the input value is any callable function, including regular functions, arrow functions, async functions, generator functions, and methods.