Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Zod · Module

.multipleOf

.multipleOf(value) constrains a Zod number to values that are multiples of value. Zod documents .step(value) as an alias.

How it works

.multipleOf(value) adds a numeric constraint requiring a parsed number to be an exact multiple of the supplied value. Zod documents .step(value) as an alias for the same constraint.

Syntax

z.number().multipleOf(value)

Parameters

NameTypeDescription
valuenumberThe number that every accepted value must be a multiple of.

Returns

A number schema with a multiple-of constraint.

Key points

  • Use .multipleOf(value) after z.number() to require values to follow a specified multiple.
  • The documented example uses 5, meaning accepted values must align with increments of five.
  • The constraint belongs to Zod's number-schema API.
  • .step(value) provides an alternate name for the same numeric constraint.

Common mistakes

  • .step(5) is an alias for .multipleOf(5), so either spelling creates the same constraint.

Example: Validate multiples

import { z } from "zod";

const schema = z.number().multipleOf(5);

console.log(schema.parse(15)); // 15
// schema.parse(12); // throws a validation error

The schema accepts numbers divisible by 5 and rejects other numbers.

When to use it

Pack-size validation

Validate quantities that must be divisible by a fixed pack size.

Step-based numeric input

Enforce numeric increments such as five-point scores or fixed measurement steps.

Interview questions

QWhat does .multipleOf() do?

It validates that a number is a multiple of the supplied value. For example, z.number().multipleOf(5) accepts 15 but rejects 12.

Follow-up: What equivalent API does the documentation provide? .step(5) is documented as an alias for .multipleOf(5).

QHow do you declare a multiple-of constraint in Zod?

Call it on a number schema and pass the interval as an argument, such as z.number().multipleOf(5). The resulting schema keeps the number type while adding the divisibility check.

Follow-up: How would you express the same rule with the alternate spelling? Use z.number().step(5).

QWhat does the argument to .multipleOf() represent?

The documented declaration is z.number().multipleOf(5), and the argument specifies the required multiple. Values that do not satisfy that multiple fail validation.

Follow-up: Which related numeric constraints can be combined with it? The same documented number API lists bounds and sign checks such as .gt(), .gte(), .lt(), .lte(), .positive(), and .nonnegative().

  • step
  • number
  • gt
  • gte
  • lt
  • lte
  • positive
  • negative

Source: Defining schemas | Zod. Checked 2026-10-15.