MCPcopy Create free account
hub / github.com/Effect-TS/effect / compileCheck

Function compileCheck

packages/effect/src/internal/schema/toCodeDocument.ts:333–354  ·  view source on GitHub ↗
(
    check: SchemaRepresentation.Check,
    path: Path
  )

Source from the content-addressed store, hash-verified

331 }
332
333 function compileCheck(
334 check: SchemaRepresentation.Check,
335 path: Path
336 ): string {
337 const callback = check.annotations?.toCode
338 let runtime: string
339 if (callback !== undefined) {
340 const schemas = annotationSchemas(check.representation, [...path, "representation"])
341 const output = (callback as SchemaRepresentation.Generation.Check)({ schemas })
342 for (const importDeclaration of output.importDeclarations ?? []) addImport(importDeclaration)
343 runtime = output.runtime
344 } else if (check._tag === "Filter") {
345 throw errorWithPath("Missing toCode callback", [...path, "annotations", "toCode"])
346 } else {
347 runtime = `Schema.makeFilterGroup([${
348 check.checks.map((child, index) => compileCheck(child, [...path, "checks", index])).join(", ")
349 }])`
350 }
351 runtime += runtimeAnnotate(check.annotations)
352 if (check._tag === "Filter" && check.aborted) runtime += ".abort()"
353 return runtime
354 }
355
356 function applyNode(
357 base: SchemaRepresentation.Code,

Callers 1

applyNodeFunction · 0.70

Calls 6

errorWithPathFunction · 0.90
addImportFunction · 0.85
runtimeAnnotateFunction · 0.85
joinMethod · 0.80
annotationSchemasFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected