Skip to main content
Use "type": "integer" when decimal values are not valid.

Common constraints

{
  "type": "object",
  "properties": {
    "count": { "type": "integer", "minimum": 0 },
    "priority": { "type": "integer", "minimum": 1, "maximum": 5 },
    "even_id": { "type": "integer", "multipleOf": 2 }
  },
  "required": ["count", "priority", "even_id"],
  "additionalProperties": false
}
from pydantic import BaseModel, ConfigDict, Field

class Payload(BaseModel):
    model_config = ConfigDict(extra="forbid")

    count: int = Field(..., ge=0)
    priority: int = Field(..., ge=1, le=5)
    even_id: int = Field(..., multiple_of=2)
import { z } from "zod";

const payloadSchema = z
  .object({
    count: z.number().int().min(0),
    priority: z.number().int().min(1).max(5),
    even_id: z.number().int().multipleOf(2),
  })
  .strict();
integer supports the same numeric bound keywords as number (minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf).

When to use

  • Use integer for counters, indexes, and IDs.
  • Use number when decimals are allowed.