import {
  err,
  ok
} from "./chunk-C7KWYVS3.js";

// src/shared/neverthrow/parse/index.ts
import z from "zod";
var type = "json";
var parseErr = (surface, error) => err(type, surface, error);
var safeParse = (surface, schema, value) => {
  const parseResult = schema.safeParse(value);
  if (!parseResult.success) {
    return parseErr(surface, {
      cause: "invalid_data",
      message: JSON.stringify(z.treeifyError(parseResult.error), null, 2),
      error: parseResult.error
    });
  }
  return ok(parseResult.data);
};

export {
  safeParse
};
//# sourceMappingURL=chunk-NROPRHIC.js.map