mirror of
https://github.com/morluto/rea.git
synced 2026-11-23 15:05:51 +00:00
fix(reconstruction): share authenticated obligation ledger sources
This commit is contained in:
1 parent
47353e494d
commit
db2a3174f6
14 files changed
+467
-416
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
import type { z } from "zod";
|
||||
|
||||
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
||||
import type { AnalysisInputError } from "../domain/analysisErrorCore.js";
|
||||
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
|
||||
|
||||
/** Project schema issues of the raw request onto their request paths. */
|
||||
@@ -10,25 +10,3 @@ export const requestInputError = (
|
||||
input: unknown,
|
||||
): AnalysisInputError =>
|
||||
analysisInputErrorFromIssues(operation, cause.issues, input, { cause });
|
||||
|
||||
/**
|
||||
* Keep the failed constraint when a parsed request is rejected later. Nested
|
||||
* values such as Evidence results are parsed on their own, so their issue
|
||||
* paths are relative to that value and are reported in the message, not as
|
||||
* request paths.
|
||||
*/
|
||||
export const workflowInputError = (
|
||||
operation: string,
|
||||
cause: z.ZodError | TypeError,
|
||||
): AnalysisInputError =>
|
||||
new AnalysisInputError(
|
||||
operation,
|
||||
{ cause },
|
||||
cause instanceof z.ZodError
|
||||
? cause.issues.map((issue) => ({
|
||||
path: [],
|
||||
reason: "invalid_value" as const,
|
||||
message: `A nested value failed validation at ${issue.path.length === 0 ? "its root" : issue.path.map(String).join(".")}: ${issue.message}`,
|
||||
}))
|
||||
: [{ path: [], reason: "invalid_value", message: cause.message }],
|
||||
);
|
||||
Reference in new issue
Block a user