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

Function compileCheck

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

Source from the content-addressed store, hash-verified

294 }
295
296 function compileCheck(
297 check: SchemaRepresentation.Check,
298 path: Path
299 ): Fragment {
300 const callback = BuiltIns.resolveCheck(check, path)
301 let runtime: Fragment
302 if (callback !== undefined) {
303 const schemas = annotationSchemas(check.representation, [...path, "representation"])
304 runtime = compileCallback(
305 schemas,
306 (schemas) => callback({ schemas }),
307 [...path, "annotations", "toCode"]
308 ).runtime
309 } else if (check._tag === "Filter") {
310 throw errorWithPath("Missing toCode callback", [...path, "annotations", "toCode"])
311 } else {
312 runtime = code`${schemaImport}.makeFilterGroup([${
313 join(check.checks.map((child, index) => compileCheck(child, [...path, "checks", index])), ", ")
314 }])`
315 }
316 runtime = code`${runtime}${runtimeAnnotate(check.annotations)}`
317 if (check._tag === "Filter" && check.aborted) runtime = code`${runtime}.abort()`
318 return runtime
319 }
320
321 function applyNode(
322 base: Code,

Callers 1

applyNodeFunction · 0.70

Calls 8

errorWithPathFunction · 0.90
codeFunction · 0.90
joinFunction · 0.90
annotationSchemasFunction · 0.85
compileCallbackFunction · 0.85
runtimeAnnotateFunction · 0.85
callbackFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected