Skip to content
masterclass Buddy

Zod · Method

.startsWith

Use .startsWith() to require that a string begins with a specified prefix. It is a built-in check on a Zod string schema.

Last updated

Syntax

z.string().startsWith(prefix, options?)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • z.string()
  • endsWith
  • includes
  • regex
  • min
  • max
  • parse

Source: Defining schemas | Zod. Checked 2026-11-03.