String validation methods in Zod
z.string() supports the following validation methods: .max(n), .min(n), .length(n), .nonempty() (alias for .min(1)), .regex(pattern), .startsWith(string), .endsWith(string), .includes(string), .uppercase(), .lowercase(). In Zod Mini, these use .check() with named functions like z.maxLength(), z.minLength(), z.length(), z.regex(), z.startsWith(), z.endsWith(), z.includes(), z.uppercase(), z.lowercase().
String transform methods in Zod
z.string() supports the following transform methods: .trim() to trim whitespace, .toLowerCase() to convert to lowercase, .toUpperCase() to convert to uppercase, .normalize() to normalize unicode characters. In Zod Mini these use .check() with z.trim(), z.toLowerCase(), z.toUpperCase(), z.normalize().
Boolean validation
z.boolean() validates boolean values. z.boolean().parse(true) returns true, z.boolean().parse(false) returns false.
Date validation
z.date() validates Date instances. Use z.date().min(date) to set minimum date and z.date().max(date) to set maximum date. Customize error messages with z.date({ error: issue => string }). In Zod Mini, constraints use .check() with z.minimum() and z.maximum().
z.stringbool() for parsing boolish strings
Introduced in zod@4.0. z.stringbool() parses string 'boolish' values to plain boolean. Default truthy values: ['true', '1', 'yes', 'on', 'y', 'enabled']. Default falsy values: ['false', '0', 'no', 'off', 'n', 'disabled']. Case-insensitive by default; make case-sensitive with z.stringbool({ case: 'sensitive' }). Customize truthy/falsy values: z.stringbool({ truthy: [...], falsy: [...] }).
z.json() validates JSON-encodable values
z.json() validates any JSON-encodable value. It returns a union schema of: string, number, boolean, null, array(jsonSchema), and record(string, jsonSchema) - a recursive definition supporting nested structures.
z.stringbool() for environment-style boolean coercion
z.stringbool() parses strings to booleans with environment-style logic. Truthy values: 'true', '1', 'yes', 'on', 'y', 'enabled'. Falsy values: 'false', '0', 'no', 'off', 'n', 'disabled'. Any other value throws a ZodError.
z.stringbool() custom truthy and falsy values
Customize z.stringbool() behavior with options: z.stringbool({ truthy: ['yes', 'true'], falsy: ['no', 'false'] })