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

Function makeStruct

packages/effect/src/Schema.ts:3521–3535  ·  view source on GitHub ↗
(ast: SchemaAST.Objects, fields: Fields)

Source from the content-addressed store, hash-verified

3519}
3520
3521function makeStruct<const Fields extends Struct.Fields>(ast: SchemaAST.Objects, fields: Fields): Struct<Fields> {
3522 return make(ast, {
3523 fields,
3524 mapFields<To extends Struct.Fields>(
3525 this: Struct<Fields>,
3526 f: (fields: Fields) => To,
3527 options?: {
3528 readonly unsafePreserveChecks?: boolean | undefined
3529 } | undefined
3530 ): Struct<To> {
3531 const fields = f(this.fields)
3532 return makeStruct(SchemaAST.struct(fields, options?.unsafePreserveChecks ? this.ast.checks : undefined), fields)
3533 }
3534 })
3535}
3536
3537/**
3538 * Defines a struct schema from a map of field schemas.

Callers 3

mapFieldsFunction · 0.85
StructFunction · 0.85
extendMethod · 0.85

Calls 1

makeFunction · 0.70

Tested by

no test coverage detected