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

Zod · Module

.lt

z.number().lt(value) validates finite numbers that are strictly less than value. It adds an exclusive upper bound to a Zod number schema.

How it works

.lt(value) adds an exclusive upper-bound check to a number schema. The schema first validates that the input is a finite number, then accepts it only when it is strictly less than the supplied limit.

Syntax

z.number().lt(value)

Parameters

NameTypeDescription
valuenumberExclusive upper-bound threshold that the validated number must be strictly less than.

Returns

A Zod number schema that accepts finite numbers strictly less than the supplied threshold.

Key points

  • .lt() is a number-specific constraint and should be chained from z.number().
  • The base number schema accepts finite numeric values; .lt(limit) narrows that set to values below the limit.
  • The method is called with one threshold argument, as shown by the official declaration example.
  • .lte() is the related inclusive upper-bound method; use it when the threshold itself should pass.

Example: Validate a number below an exclusive upper bound

import { z } from "zod";

const schema = z.number().lt(10);

console.log(schema.safeParse(9).success);  // true
console.log(schema.safeParse(10).success); // false

Creates a number schema that accepts values below 10 and rejects 10 or greater.

When to use it

Exclusive maximum validation

Reject an input at or above a configured ceiling, such as a quantity that must remain below a maximum.

Strict range constraints

Validate a numeric field whose boundary value is intentionally invalid, such as a zero-based index below a collection length.

Interview questions

QWhat does .lt(5) validate?

z.number().lt(5) accepts finite numbers strictly smaller than 5. The boundary value 5 fails because the comparison is exclusive.

Follow-up: How would you allow 5 as well? Use z.number().lte(5), which applies an inclusive upper bound.

QHow do you use .lt() in a Zod schema?

It is chained after z.number() and receives the maximum threshold as its argument: z.number().lt(5). The resulting schema remains a number schema with the additional upper-bound constraint.

Follow-up: What happens to non-numbers? They fail the underlying z.number() validation before the limit comparison is relevant.

QHow does .lt() differ from the related number constraints?

The documented number-specific methods include .gt(), .gte(), .lt(), and .lte(). Among these, .lt() is the strict upper-bound validator, while .lte() permits the threshold itself.

Follow-up: Which documented aliases correspond to inclusive bounds? .gte() is aliased by .min(), and .lte() is aliased by .max().

  • z.number()
  • z.number().gt()
  • z.number().gte()
  • z.number().lte()
  • z.number().positive()

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