Struct<{
readonly issues: $Array<
Struct<{
readonly message: String
readonly path: optional<
$Array<
Union<
readonly [
Union<readonly [Finite, Symbol, String]>,
Struct<{
readonly key: Union<readonly [Finite, Symbol, String]>
}>
]
>
>
>
}>
>
}>Schema for a Standard Schema v1 failure result.
Details
The result contains an issues array where each issue has a message and an
optional path made of property keys or keyed path segments.
export const const StandardSchemaV1FailureResult: Struct<{
readonly issues: $Array<
Struct<{
readonly message: String
readonly path: optional<
$Array<
Union<
readonly [
Union<
readonly [Finite, Symbol, String]
>,
Struct<{
readonly key: Union<
readonly [
Finite,
Symbol,
String
]
>
}>
]
>
>
>
}>
>
}>
const StandardSchemaV1FailureResult: {
Type: Struct.Type<Fields>;
Encoded: Struct.Encoded<Fields>;
DecodingServices: Struct.DecodingServices<Fields>;
EncodingServices: Struct.EncodingServices<Fields>;
Iso: Struct.Iso<Fields>;
fields: Fields;
mapFields: (f: (fields: { readonly issues: $Array<Struct<{ readonly message: String; readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{ readonly key: Union<readonly [Finite, Symbol, String]> }>]>>> }>> }…;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Annotations.Bottom<Struct.ReadonlySide<{ readonly issues: $Array<Struct<{ readonly message: String; readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{ readonly key: Union<readonl…;
annotateKey: (annotations: Annotations.Key<Struct.ReadonlySide<{ readonly issues: $Array<Struct<{ readonly message: String; readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{ readonly key: Union<readonly […;
check: (checks_0: SchemaAST.Check<Struct.ReadonlySide<{ readonly issues: $Array<Struct<{ readonly message: String; readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{ readonly key: Union<readonly [Fin…;
rebuild: (ast: SchemaAST.Objects) => Struct<{ readonly issues: $Array<Struct<{ readonly message: String; readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{ readonly key: Union<readonly [Finite, Symbol,…;
make: (input: Struct.ReadonlyMakeIn<{ readonly issues: $Array<Struct<{ readonly message: String; readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{ readonly key: Union<readonly [Finite, Symbol, Stri…;
makeOption: (input: Struct.ReadonlyMakeIn<{ readonly issues: $Array<Struct<{ readonly message: String; readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{ readonly key: Union<readonly [Finite, Symbol, Stri…;
makeEffect: (input: Struct.ReadonlyMakeIn<{ readonly issues: $Array<Struct<{ readonly message: String; readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{ readonly key: Union<readonly [Finite, Symbol, Stri…;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Schema for a Standard Schema v1 failure result.
Details
The result contains an issues array where each issue has a message and an
optional path made of property keys or keyed path segments.
StandardSchemaV1FailureResult = function Struct<
Fields extends Struct.Fields
>(fields: Fields): Struct<Fields>
Defines a struct schema from a map of field schemas.
Details
Each field value is a schema. Use
optionalKey
or
optional
to
mark fields as optional, and
mutableKey
to mark them as mutable.
The resulting schema's Type is a readonly object type with the fields'
decoded types. The Encoded form mirrors the field schemas' encoded types.
Example (Defining a basic struct)
import { Schema } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number,
email: Schema.optionalKey(Schema.String)
})
// { readonly name: string; readonly age: number; readonly email?: string }
type Person = typeof Person.Type
const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
console.log(alice)
// { name: 'Alice', age: 30 }
Struct({
issues: $Array<
Struct<{
readonly message: String
readonly path: optional<
$Array<
Union<
readonly [
Union<
readonly [Finite, Symbol, String]
>,
Struct<{
readonly key: Union<
readonly [Finite, Symbol, String]
>
}>
]
>
>
>
}>
>
(property) issues: {
Type: ReadonlyArray<S["Type"]>;
Encoded: ReadonlyArray<S["Encoded"]>;
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: ReadonlyArray<S["Iso"]>;
value: S;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Annotations.Bottom<ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray<string | number | symbol | Struct.ReadonlySide<{ readonly key: Union<readonly [Finite, Symbol, String]>; }, 'Type'>> | undefined; }>, …;
annotateKey: (annotations: Annotations.Key<ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray<string | number | symbol | Struct.ReadonlySide<{ readonly key: Union<readonly [Finite, Symbol, String]> }, 'Type'>> | undefined }>>) => $…;
check: (checks_0: SchemaAST.Check<ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray<string | number | symbol | Struct.ReadonlySide<{ readonly key: Union<readonly [Finite, Symbol, String]> }, 'Type'>> | undefined }>>, ...chec…;
rebuild: (ast: SchemaAST.Arrays) => $Array<Struct<{ readonly message: String; readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{ readonly key: Union<readonly [Finite, Symbol, String]> }>]>>> }>>;
make: (input: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray<string | number | symbol | Struct.ReadonlyMakeIn<{ readonly key: Union<readonly [Finite, Symbol, String]> }>> | undefined }>, options?: MakeOptions) => Readonl…;
makeOption: (input: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray<string | number | symbol | Struct.ReadonlyMakeIn<{ readonly key: Union<readonly [Finite, Symbol, String]> }>> | undefined }>, options?: MakeOptions) => Option_…;
makeEffect: (input: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray<string | number | symbol | Struct.ReadonlyMakeIn<{ readonly key: Union<readonly [Finite, Symbol, String]> }>> | undefined }>, options?: MakeOptions) => Effect.…;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
issues: const ArraySchema: ArrayLambda
<Struct<{
readonly message: String;
readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{
readonly key: Union<readonly [Finite, Symbol, String]>;
}>]>>>;
}>>(self: Struct<{
readonly message: String;
readonly path: optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{
readonly key: Union<readonly [Finite, Symbol, String]>;
}>]>>>;
}>) => $Array<...>
ArraySchema(function Struct<
Fields extends Struct.Fields
>(fields: Fields): Struct<Fields>
Defines a struct schema from a map of field schemas.
Details
Each field value is a schema. Use
optionalKey
or
optional
to
mark fields as optional, and
mutableKey
to mark them as mutable.
The resulting schema's Type is a readonly object type with the fields'
decoded types. The Encoded form mirrors the field schemas' encoded types.
Example (Defining a basic struct)
import { Schema } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number,
email: Schema.optionalKey(Schema.String)
})
// { readonly name: string; readonly age: number; readonly email?: string }
type Person = typeof Person.Type
const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
console.log(alice)
// { name: 'Alice', age: 30 }
Struct({
message: String(property) message: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<string, readonly []>) => String;
annotateKey: (annotations: Annotations.Key<string>) => String;
check: (checks_0: SchemaAST.Check<string>, ...checks: Array<SchemaAST.Check<string>>) => String;
rebuild: (ast: SchemaAST.String) => String;
make: (input: string, options?: MakeOptions) => string;
makeOption: (input: string, options?: MakeOptions) => Option_.Option<string>;
makeEffect: (input: string, options?: MakeOptions) => Effect.Effect<string, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
message: const String: Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<string, readonly []>) => String;
annotateKey: (annotations: Annotations.Key<string>) => String;
check: (checks_0: SchemaAST.Check<string>, ...checks: Array<SchemaAST.Check<string>>) => String;
rebuild: (ast: SchemaAST.String) => String;
make: (input: string, options?: MakeOptions) => string;
makeOption: (input: string, options?: MakeOptions) => Option_.Option<string>;
makeEffect: (input: string, options?: MakeOptions) => Effect.Effect<string, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
String
.
Schema for string values. Validates that the input is typeof "string".
String,
path: optional<
$Array<
Union<
readonly [
Union<readonly [Finite, Symbol, String]>,
Struct<{
readonly key: Union<
readonly [Finite, Symbol, String]
>
}>
]
>
>
>
(property) path: {
Rebuild: optional<S>;
Type: S["Type"];
Encoded: S["Encoded"];
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: S["Iso"];
schema: S;
ast: Ast;
annotate: (annotations: Annotations.Bottom<ReadonlyArray<string | number | symbol | Struct.ReadonlySide<{ readonly key: Union<readonly [Finite, Symbol, String]>; }, 'Type'>> | undefined, readonly []>) => optional<$Array<Union<readonly [Union<readonl…;
annotateKey: (annotations: Annotations.Key<ReadonlyArray<string | number | symbol | Struct.ReadonlySide<{ readonly key: Union<readonly [Finite, Symbol, String]> }, 'Type'>> | undefined>) => optional<$Array<Union<readonly [Union<readonly [Finite, Symbol…;
check: (checks_0: SchemaAST.Check<ReadonlyArray<string | number | symbol | Struct.ReadonlySide<{ readonly key: Union<readonly [Finite, Symbol, String]> }, 'Type'>> | undefined>, ...checks: Array<SchemaAST.Check<ReadonlyArray<string | number | sym…;
rebuild: (ast: SchemaAST.Union<SchemaAST.Undefined | SchemaAST.Arrays>) => optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{ readonly key: Union<readonly [Finite, Symbol, String]> }>]>>>;
make: (input: ReadonlyArray<string | number | symbol | Struct.ReadonlyMakeIn<{ readonly key: Union<readonly [Finite, Symbol, String]> }>> | undefined, options?: MakeOptions) => ReadonlyArray<string | number | symbol | Struct.ReadonlySide<{ reado…;
makeOption: (input: ReadonlyArray<string | number | symbol | Struct.ReadonlyMakeIn<{ readonly key: Union<readonly [Finite, Symbol, String]> }>> | undefined, options?: MakeOptions) => Option_.Option<ReadonlyArray<string | number | symbol | Struct.Reado…;
makeEffect: (input: ReadonlyArray<string | number | symbol | Struct.ReadonlyMakeIn<{ readonly key: Union<readonly [Finite, Symbol, String]> }>> | undefined, options?: MakeOptions) => Effect.Effect<ReadonlyArray<string | number | symbol | Struct.Readon…;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
path: const optional: optionalLambda
<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{
readonly key: Union<readonly [Finite, Symbol, String]>;
}>]>>>(self: $Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{
readonly key: Union<readonly [Finite, Symbol, String]>;
}>]>>) => optional<$Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{
readonly key: Union<readonly [Finite, Symbol, String]>;
}>]>>>
Type-level representation returned by
optional
.
Marks a struct field as optional, allowing the key to be absent or
undefined.
Details
The resulting property may be absent or explicitly set to undefined.
Equivalent to optionalKey(UndefinedOr(S)).
Use
optionalKey
instead if you want exact optional semantics (absent
only, not undefined).
Example (Defining an optional field accepting undefined)
import { Schema } from "effect"
const schema = Schema.Struct({
name: Schema.String,
age: Schema.optional(Schema.Number)
})
// { readonly name: string; readonly age?: number | undefined }
type Person = typeof schema.Type
optional(const ArraySchema: ArrayLambda
<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{
readonly key: Union<readonly [Finite, Symbol, String]>;
}>]>>(self: Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{
readonly key: Union<readonly [Finite, Symbol, String]>;
}>]>) => $Array<Union<readonly [Union<readonly [Finite, Symbol, String]>, Struct<{
readonly key: Union<readonly [Finite, Symbol, String]>;
}>]>>
ArraySchema(function Union<
Members extends ReadonlyArray<Constraint>
>(
members: Members,
options?: { mode?: "anyOf" | "oneOf" }
): Union<Members>
Creates a union schema from an array of member schemas. Members are tested in
order; the first match is returned.
Details
Optionally, specify mode:
"anyOf" (default) — matches if any member matches.
"oneOf" — matches if exactly one member matches.
Example (Defining a string or number union)
import { Schema } from "effect"
const schema = Schema.Union([Schema.String, Schema.Number])
Schema.decodeUnknownSync(schema)("hello") // "hello"
Schema.decodeUnknownSync(schema)(42) // 42
Union([const PropertyKey: Union<
readonly [Finite, Symbol, String]
>
const PropertyKey: {
Type: { [K in keyof Members]: Members[K]["Type"]; }[number];
Encoded: { [K in keyof Members]: Members[K]["Encoded"]; }[number];
DecodingServices: { [K in keyof Members]: Members[K]["DecodingServices"]; }[number];
EncodingServices: { [K in keyof Members]: Members[K]["EncodingServices"]; }[number];
Iso: { [K in keyof Members]: Members[K]["Iso"]; }[number];
members: Members;
mapMembers: (f: (members: readonly [Finite, Symbol, String]) => To, options?: { readonly unsafePreserveChecks?: boolean | undefined } | undefined) => Union<{ [K in keyof Readonly<To>]: Readonly<To>[K]; }>;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Annotations.Bottom<string | number | symbol, readonly []>) => Union<readonly [Finite, Symbol, String]>;
annotateKey: (annotations: Annotations.Key<string | number | symbol>) => Union<readonly [Finite, Symbol, String]>;
check: (checks_0: SchemaAST.Check<string | number | symbol>, ...checks: Array<SchemaAST.Check<string | number | symbol>>) => Union<readonly [Finite, Symbol, String]>;
rebuild: (ast: SchemaAST.Union<SchemaAST.String | SchemaAST.Number | SchemaAST.Symbol>) => Union<readonly [Finite, Symbol, String]>;
make: (input: string | number | symbol, options?: MakeOptions) => string | number | symbol;
makeOption: (input: string | number | symbol, options?: MakeOptions) => Option_.Option<string | number | symbol>;
makeEffect: (input: string | number | symbol, options?: MakeOptions) => Effect.Effect<string | number | symbol, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Schema for property keys accepted by Effect schemas: finite number,
symbol, or string.
PropertyKey, function Struct<
Fields extends Struct.Fields
>(fields: Fields): Struct<Fields>
Defines a struct schema from a map of field schemas.
Details
Each field value is a schema. Use
optionalKey
or
optional
to
mark fields as optional, and
mutableKey
to mark them as mutable.
The resulting schema's Type is a readonly object type with the fields'
decoded types. The Encoded form mirrors the field schemas' encoded types.
Example (Defining a basic struct)
import { Schema } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number,
email: Schema.optionalKey(Schema.String)
})
// { readonly name: string; readonly age: number; readonly email?: string }
type Person = typeof Person.Type
const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
console.log(alice)
// { name: 'Alice', age: 30 }
Struct({ key: Union<readonly [Finite, Symbol, String]>(property) key: {
Type: { [K in keyof Members]: Members[K]["Type"]; }[number];
Encoded: { [K in keyof Members]: Members[K]["Encoded"]; }[number];
DecodingServices: { [K in keyof Members]: Members[K]["DecodingServices"]; }[number];
EncodingServices: { [K in keyof Members]: Members[K]["EncodingServices"]; }[number];
Iso: { [K in keyof Members]: Members[K]["Iso"]; }[number];
members: Members;
mapMembers: (f: (members: readonly [Finite, Symbol, String]) => To, options?: { readonly unsafePreserveChecks?: boolean | undefined } | undefined) => Union<{ [K in keyof Readonly<To>]: Readonly<To>[K]; }>;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Annotations.Bottom<string | number | symbol, readonly []>) => Union<readonly [Finite, Symbol, String]>;
annotateKey: (annotations: Annotations.Key<string | number | symbol>) => Union<readonly [Finite, Symbol, String]>;
check: (checks_0: SchemaAST.Check<string | number | symbol>, ...checks: Array<SchemaAST.Check<string | number | symbol>>) => Union<readonly [Finite, Symbol, String]>;
rebuild: (ast: SchemaAST.Union<SchemaAST.String | SchemaAST.Number | SchemaAST.Symbol>) => Union<readonly [Finite, Symbol, String]>;
make: (input: string | number | symbol, options?: MakeOptions) => string | number | symbol;
makeOption: (input: string | number | symbol, options?: MakeOptions) => Option_.Option<string | number | symbol>;
makeEffect: (input: string | number | symbol, options?: MakeOptions) => Effect.Effect<string | number | symbol, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
key: const PropertyKey: Union<
readonly [Finite, Symbol, String]
>
const PropertyKey: {
Type: { [K in keyof Members]: Members[K]["Type"]; }[number];
Encoded: { [K in keyof Members]: Members[K]["Encoded"]; }[number];
DecodingServices: { [K in keyof Members]: Members[K]["DecodingServices"]; }[number];
EncodingServices: { [K in keyof Members]: Members[K]["EncodingServices"]; }[number];
Iso: { [K in keyof Members]: Members[K]["Iso"]; }[number];
members: Members;
mapMembers: (f: (members: readonly [Finite, Symbol, String]) => To, options?: { readonly unsafePreserveChecks?: boolean | undefined } | undefined) => Union<{ [K in keyof Readonly<To>]: Readonly<To>[K]; }>;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Annotations.Bottom<string | number | symbol, readonly []>) => Union<readonly [Finite, Symbol, String]>;
annotateKey: (annotations: Annotations.Key<string | number | symbol>) => Union<readonly [Finite, Symbol, String]>;
check: (checks_0: SchemaAST.Check<string | number | symbol>, ...checks: Array<SchemaAST.Check<string | number | symbol>>) => Union<readonly [Finite, Symbol, String]>;
rebuild: (ast: SchemaAST.Union<SchemaAST.String | SchemaAST.Number | SchemaAST.Symbol>) => Union<readonly [Finite, Symbol, String]>;
make: (input: string | number | symbol, options?: MakeOptions) => string | number | symbol;
makeOption: (input: string | number | symbol, options?: MakeOptions) => Option_.Option<string | number | symbol>;
makeEffect: (input: string | number | symbol, options?: MakeOptions) => Effect.Effect<string | number | symbol, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Schema for property keys accepted by Effect schemas: finite number,
symbol, or string.
PropertyKey })])))
}))
})