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:
Schema.String
with anotherSchema.String
refinement or a string literalSchema.Number
with anotherSchema.Number
refinement or a number literalSchema.Boolean
with anotherSchema.Boolean
refinement or a boolean literal- A struct with another struct where overlapping fields support extension
- A struct with in index signature
- A struct with a union of supported schemas
- A refinement of a struct with a supported schema
- A suspend of a struct with a supported schema
- A transformation between structs where the “from” and “to” sides have no overlapping fields with the target struct
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))
Since
3.10.0
Call Signature
extend<
That
>(that
): <Self
>(self
) =>extend
<Self
,That
>
Defined in: node_modules/.pnpm/effect@3.14.8/node_modules/effect/dist/dts/Schema.d.ts:1747
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:
Schema.String
with anotherSchema.String
refinement or a string literalSchema.Number
with anotherSchema.Number
refinement or a number literalSchema.Boolean
with anotherSchema.Boolean
refinement or a boolean literal- A struct with another struct where overlapping fields support extension
- A struct with in index signature
- A struct with a union of supported schemas
- A refinement of a struct with a supported schema
- A suspend of a struct with a supported schema
- A transformation between structs where the “from” and “to” sides have no overlapping fields with the target struct
Type Parameters
• That extends Any
Parameters
that
That
Returns
Function
Type Parameters
• Self extends Any
Parameters
self
Self
Returns
extend
<Self
, That
>
Examples
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))
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))
Since
3.10.0
Since
3.10.0
Call Signature
extend<
Self
,That
>(self
,that
):extend
<Self
,That
>
Defined in: node_modules/.pnpm/effect@3.14.8/node_modules/effect/dist/dts/Schema.d.ts:1795
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:
Schema.String
with anotherSchema.String
refinement or a string literalSchema.Number
with anotherSchema.Number
refinement or a number literalSchema.Boolean
with anotherSchema.Boolean
refinement or a boolean literal- A struct with another struct where overlapping fields support extension
- A struct with in index signature
- A struct with a union of supported schemas
- A refinement of a struct with a supported schema
- A suspend of a struct with a supported schema
- A transformation between structs where the “from” and “to” sides have no overlapping fields with the target struct
Type Parameters
• Self extends Any
• That extends Any
Parameters
self
Self
that
That
Returns
extend
<Self
, That
>
Examples
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))
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))
Since
3.10.0
Since
3.10.0