compat.js 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. // Zod 3 compat layer
  2. import * as core from "zod/v4/core";
  3. /** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
  4. export const ZodIssueCode = {
  5. invalid_type: "invalid_type",
  6. too_big: "too_big",
  7. too_small: "too_small",
  8. invalid_format: "invalid_format",
  9. not_multiple_of: "not_multiple_of",
  10. unrecognized_keys: "unrecognized_keys",
  11. invalid_union: "invalid_union",
  12. invalid_key: "invalid_key",
  13. invalid_element: "invalid_element",
  14. invalid_value: "invalid_value",
  15. custom: "custom",
  16. };
  17. /** @deprecated Not necessary in Zod 4. */
  18. const INVALID = Object.freeze({
  19. status: "aborted",
  20. });
  21. /** A special constant with type `never` */
  22. export const NEVER = INVALID;
  23. export { $brand, config } from "zod/v4/core";
  24. /** @deprecated Use `z.config(params)` instead. */
  25. export function setErrorMap(map) {
  26. core.config({
  27. customError: map,
  28. });
  29. }
  30. /** @deprecated Use `z.config()` instead. */
  31. export function getErrorMap() {
  32. return core.config().customError;
  33. }