| 4 | import { KernelCoreEffectError } from "./effect-errors"; |
| 5 | |
| 6 | const getSchemaValidator = ( |
| 7 | schema: unknown, |
| 8 | ): |
| 9 | | (( |
| 10 | value: unknown, |
| 11 | ) => StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>) |
| 12 | | null => { |
| 13 | if (!schema || (typeof schema !== "object" && typeof schema !== "function")) { |
| 14 | return null; |
| 15 | } |
| 16 | |
| 17 | const standard = (schema as { "~standard"?: unknown })["~standard"]; |
| 18 | if (!standard || typeof standard !== "object") { |
| 19 | return null; |
| 20 | } |
| 21 | |
| 22 | const validate = (standard as { validate?: unknown }).validate; |
| 23 | return typeof validate === "function" |
| 24 | ? (validate as ( |
| 25 | value: unknown, |
| 26 | ) => StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>) |
| 27 | : null; |
| 28 | }; |
| 29 | |
| 30 | const formatIssuePath = ( |
| 31 | path: ReadonlyArray<PropertyKey | StandardSchemaV1.PathSegment> | undefined, |