Skip to content
Zap Studio
validation
Esc
navigateopen⌘Jpreview
On this page

Synchronous Validation

Validate values synchronously with standardValidateSync, for schemas known to validate synchronously.

standardValidateSync is for schemas known to validate synchronously — use it only when validation must remain synchronous end-to-end, for example in sync-only code paths or constrained runtimes.

import { standardValidateSync } from "@zap-studio/validation";
import { z } from "zod";

const userSchema = z.object({
  name: z.string(),
  age: z.number(),
});

const result = standardValidateSync(input, userSchema);

if (result.issues) {
  console.error("Validation failed", result.issues);
} else {
  console.log("Validation passed", result.value);
}

It supports the same throwOnError option as standardValidate:

const user = standardValidateSync(input, userSchema, {
  throwOnError: true,
});

See Also

  • Async Validation — the default choice, works with sync and async schemas
  • Create ValidatorscreateStandardValidatorSync for a reusable sync validator
  • ErrorsthrowOnError and ValidationError

Last updated on September 21, 2026

Was this page helpful?