effect-io-ai

Package: effect
Module: Schema

Schema.extend

Extends a schema with another schema.

Not all extensions are supported, and their support depends on the nature of the involved schemas.

Possible extensions include:

Example

import * as Schema from "effect/Schema"

const schema = Schema.Struct({
  a: Schema.String,
  b: Schema.String
})

// const extended: Schema<
//   {
//     readonly a: string
//     readonly b: string
//   } & {
//     readonly c: string
//   } & {
//     readonly [x: string]: string
//   }
// >
const extended = Schema.asSchema(schema.pipe(
  Schema.extend(Schema.Struct({ c: Schema.String })), // <= you can add more fields
  Schema.extend(Schema.Record({ key: Schema.String, value: Schema.String })) // <= you can add index signatures
))

Signature

declare const extend: { <That extends Schema.Any>(that: That): <Self extends Schema.Any>(self: Self) => extend<Self, That>; <Self extends Schema.Any, That extends Schema.Any>(self: Self, that: That): extend<Self, That>; }

Source

Since v3.10.0