Skip to main content

Import

What it does

ResponseValidator validates runtime data against a lightweight schema shape. Use it when you want built-in validation without depending on Zod, Valibot, or another schema library. It checks types, required fields, string/number constraints, patterns, enums, and custom predicates.

Static method

ResponseValidator.validate(data, schema, path?)

Returns: ValidationError[] — an array of errors. Empty means valid.

ValidationError

ValidationSchema

Examples

Basic object validation

Array with item schema

Custom validator

Using with ApiClient

You can pass a ValidationSchema directly to the validateResponse option on any ApiClient request:
For more expressive schemas, consider using Zod or Valibot adapters instead. ResponseValidator is ideal when you want zero external dependencies.

When to use it

  • You want a package-native validator with no extra dependencies
  • You only need structural and constraint checks at runtime
  • You want to keep your bundle lean