<Sch extends Schema.Top>(itemSchema: Sch): Schema.Struct<{
readonly item: Sch
readonly entryId: Schema.String
readonly key: Schema.optional<Schema.String>
readonly priority: Schema.Literals<readonly ["high", "normal", "low"]>
readonly level: Schema.optional<Schema.Number>
readonly attempts: Schema.Number
readonly timestamps: Schema.Struct<{
readonly enqueuedAt: Schema.DateTimeUtc
readonly startedAt: Schema.optionalKey<Schema.DateTimeUtc>
readonly completedAt: Schema.optionalKey<Schema.DateTimeUtc>
readonly interruptedAt: Schema.optionalKey<Schema.DateTimeUtc>
}>
readonly batchId: Schema.optional<Schema.String>
readonly releaseId: Schema.optional<Schema.String>
readonly sourceHyperlinkId: Schema.optional<Schema.String>
readonly attributes: Schema.optional<
Schema.$Record<Schema.String, Schema.Unknown>
>
}>Custom queue entry on the wire — like queueEntry plus optional numeric level.
export const const customQueueEntry: <Sch extends Schema.Top>(itemSchema: Sch) => Schema.Struct<{
readonly item: Sch;
readonly entryId: Schema.String;
readonly key: Schema.optional<Schema.String>;
readonly priority: any;
readonly level: Schema.optional<Schema.Number>;
readonly attempts: Schema.Number;
readonly timestamps: any;
readonly batchId: Schema.optional<Schema.String>;
readonly releaseId: Schema.optional<Schema.String>;
readonly sourceHyperlinkId: Schema.optional<Schema.String>;
readonly attributes: Schema.optional<...>;
}>
Custom queue entry on the wire — like
queueEntry
plus optional numeric level.
customQueueEntry = <function (type parameter) Sch in <Sch extends Schema.Top>(itemSchema: Sch): Schema.Struct<{
readonly item: Sch;
readonly entryId: Schema.String;
readonly key: Schema.optional<Schema.String>;
readonly priority: any;
... 6 more ...;
readonly attributes: Schema.optional<...>;
}>
Sch extends import SchemaSchema.Top>(
itemSchema: Sch extends Schema.TopitemSchema: function (type parameter) Sch in <Sch extends Schema.Top>(itemSchema: Sch): Schema.Struct<{
readonly item: Sch;
readonly entryId: Schema.String;
readonly key: Schema.optional<Schema.String>;
readonly priority: any;
... 6 more ...;
readonly attributes: Schema.optional<...>;
}>
Sch,
) =>
import SchemaSchema.function Struct<{
readonly item: Sch;
readonly entryId: Schema.String;
readonly key: Schema.optional<Schema.String>;
readonly priority: any;
readonly level: Schema.optional<Schema.Number>;
readonly attempts: Schema.Number;
readonly timestamps: any;
readonly batchId: Schema.optional<Schema.String>;
readonly releaseId: Schema.optional<Schema.String>;
readonly sourceHyperlinkId: Schema.optional<Schema.String>;
readonly attributes: Schema.optional<any>;
}>(fields: {
readonly item: Sch;
readonly entryId: Schema.String;
readonly key: Schema.optional<Schema.String>;
readonly priority: any;
readonly level: Schema.optional<Schema.Number>;
readonly attempts: Schema.Number;
readonly timestamps: any;
readonly batchId: Schema.optional<Schema.String>;
readonly releaseId: Schema.optional<Schema.String>;
readonly sourceHyperlinkId: Schema.optional<Schema.String>;
readonly attributes: Schema.optional<any>;
}): Schema.Struct<...>
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({
item: Sch extends Schema.Topitem: itemSchema: Sch extends Schema.TopitemSchema,
entryId: Schema.String(property) entryId: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option.Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.Effect<string, Schema.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; <…;
}
entryId: import SchemaSchema.const String: Schema.Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option.Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.Effect<string, Schema.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,
key: Schema.optional<Schema.String>(property) key: {
Rebuild: optional<S>;
Type: S["Type"];
Encoded: S["Encoded"];
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: S["Iso"];
schema: S;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<string | undefined, readonly []>) => Schema.optional<Schema.String>;
annotateKey: (annotations: Schema.Annotations.Key<string | undefined>) => Schema.optional<Schema.String>;
check: (checks_0: Check<string | undefined>, ...checks: Array<Check<string | undefined>>) => Schema.optional<Schema.String>;
rebuild: (ast: Union<String | Undefined>) => Schema.optional<Schema.String>;
make: (input: string | undefined, options?: Schema.MakeOptions) => string | undefined;
makeOption: (input: string | undefined, options?: Schema.MakeOptions) => Option.Option<string | undefined>;
makeEffect: (input: string | undefined, options?: Schema.MakeOptions) => Effect.Effect<string | undefined, Schema.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: import SchemaSchema.const optional: optionalLambda
<Schema.String>(self: Schema.String) => Schema.optional<Schema.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(import SchemaSchema.const String: Schema.Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option.Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.Effect<string, Schema.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),
priority: anypriority: import queuePriorityqueuePriority,
level: Schema.optional<Schema.Number>(property) level: {
Rebuild: optional<S>;
Type: S["Type"];
Encoded: S["Encoded"];
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: S["Iso"];
schema: S;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<number | undefined, readonly []>) => Schema.optional<Schema.Number>;
annotateKey: (annotations: Schema.Annotations.Key<number | undefined>) => Schema.optional<Schema.Number>;
check: (checks_0: Check<number | undefined>, ...checks: Array<Check<number | undefined>>) => Schema.optional<Schema.Number>;
rebuild: (ast: Union<Undefined | Number>) => Schema.optional<Schema.Number>;
make: (input: number | undefined, options?: Schema.MakeOptions) => number | undefined;
makeOption: (input: number | undefined, options?: Schema.MakeOptions) => Option.Option<number | undefined>;
makeEffect: (input: number | undefined, options?: Schema.MakeOptions) => Effect.Effect<number | undefined, Schema.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; <…;
}
level: import SchemaSchema.const optional: optionalLambda
<Schema.Number>(self: Schema.Number) => Schema.optional<Schema.Number>
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(import SchemaSchema.const Number: Schema.Numberconst Number: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<number, readonly []>) => Schema.Number;
annotateKey: (annotations: Schema.Annotations.Key<number>) => Schema.Number;
check: (checks_0: Check<number>, ...checks: Array<Check<number>>) => Schema.Number;
rebuild: (ast: Number) => Schema.Number;
make: (input: number, options?: Schema.MakeOptions) => number;
makeOption: (input: number, options?: Schema.MakeOptions) => Option.Option<number>;
makeEffect: (input: number, options?: Schema.MakeOptions) => Effect.Effect<number, Schema.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
Number
.
Schema for number values, including NaN, Infinity, and -Infinity.
Details
Default JSON serializer:
- Finite numbers are serialized as numbers.
- Non-finite values are serialized as strings (
"NaN", "Infinity", "-Infinity").
Number),
attempts: Schema.Number(property) attempts: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<number, readonly []>) => Schema.Number;
annotateKey: (annotations: Schema.Annotations.Key<number>) => Schema.Number;
check: (checks_0: Check<number>, ...checks: Array<Check<number>>) => Schema.Number;
rebuild: (ast: Number) => Schema.Number;
make: (input: number, options?: Schema.MakeOptions) => number;
makeOption: (input: number, options?: Schema.MakeOptions) => Option.Option<number>;
makeEffect: (input: number, options?: Schema.MakeOptions) => Effect.Effect<number, Schema.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; <…;
}
attempts: import SchemaSchema.const Number: Schema.Numberconst Number: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<number, readonly []>) => Schema.Number;
annotateKey: (annotations: Schema.Annotations.Key<number>) => Schema.Number;
check: (checks_0: Check<number>, ...checks: Array<Check<number>>) => Schema.Number;
rebuild: (ast: Number) => Schema.Number;
make: (input: number, options?: Schema.MakeOptions) => number;
makeOption: (input: number, options?: Schema.MakeOptions) => Option.Option<number>;
makeEffect: (input: number, options?: Schema.MakeOptions) => Effect.Effect<number, Schema.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
Number
.
Schema for number values, including NaN, Infinity, and -Infinity.
Details
Default JSON serializer:
- Finite numbers are serialized as numbers.
- Non-finite values are serialized as strings (
"NaN", "Infinity", "-Infinity").
Number,
timestamps: anytimestamps: import queueEntryTimestampsqueueEntryTimestamps,
batchId: Schema.optional<Schema.String>(property) batchId: {
Rebuild: optional<S>;
Type: S["Type"];
Encoded: S["Encoded"];
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: S["Iso"];
schema: S;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<string | undefined, readonly []>) => Schema.optional<Schema.String>;
annotateKey: (annotations: Schema.Annotations.Key<string | undefined>) => Schema.optional<Schema.String>;
check: (checks_0: Check<string | undefined>, ...checks: Array<Check<string | undefined>>) => Schema.optional<Schema.String>;
rebuild: (ast: Union<String | Undefined>) => Schema.optional<Schema.String>;
make: (input: string | undefined, options?: Schema.MakeOptions) => string | undefined;
makeOption: (input: string | undefined, options?: Schema.MakeOptions) => Option.Option<string | undefined>;
makeEffect: (input: string | undefined, options?: Schema.MakeOptions) => Effect.Effect<string | undefined, Schema.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; <…;
}
batchId: import SchemaSchema.const optional: optionalLambda
<Schema.String>(self: Schema.String) => Schema.optional<Schema.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(import SchemaSchema.const String: Schema.Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option.Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.Effect<string, Schema.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),
releaseId: Schema.optional<Schema.String>(property) releaseId: {
Rebuild: optional<S>;
Type: S["Type"];
Encoded: S["Encoded"];
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: S["Iso"];
schema: S;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<string | undefined, readonly []>) => Schema.optional<Schema.String>;
annotateKey: (annotations: Schema.Annotations.Key<string | undefined>) => Schema.optional<Schema.String>;
check: (checks_0: Check<string | undefined>, ...checks: Array<Check<string | undefined>>) => Schema.optional<Schema.String>;
rebuild: (ast: Union<String | Undefined>) => Schema.optional<Schema.String>;
make: (input: string | undefined, options?: Schema.MakeOptions) => string | undefined;
makeOption: (input: string | undefined, options?: Schema.MakeOptions) => Option.Option<string | undefined>;
makeEffect: (input: string | undefined, options?: Schema.MakeOptions) => Effect.Effect<string | undefined, Schema.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; <…;
}
releaseId: import SchemaSchema.const optional: optionalLambda
<Schema.String>(self: Schema.String) => Schema.optional<Schema.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(import SchemaSchema.const String: Schema.Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option.Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.Effect<string, Schema.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),
sourceHyperlinkId: Schema.optional<Schema.String>(property) sourceHyperlinkId: {
Rebuild: optional<S>;
Type: S["Type"];
Encoded: S["Encoded"];
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: S["Iso"];
schema: S;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<string | undefined, readonly []>) => Schema.optional<Schema.String>;
annotateKey: (annotations: Schema.Annotations.Key<string | undefined>) => Schema.optional<Schema.String>;
check: (checks_0: Check<string | undefined>, ...checks: Array<Check<string | undefined>>) => Schema.optional<Schema.String>;
rebuild: (ast: Union<String | Undefined>) => Schema.optional<Schema.String>;
make: (input: string | undefined, options?: Schema.MakeOptions) => string | undefined;
makeOption: (input: string | undefined, options?: Schema.MakeOptions) => Option.Option<string | undefined>;
makeEffect: (input: string | undefined, options?: Schema.MakeOptions) => Effect.Effect<string | undefined, Schema.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; <…;
}
sourceHyperlinkId: import SchemaSchema.const optional: optionalLambda
<Schema.String>(self: Schema.String) => Schema.optional<Schema.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(import SchemaSchema.const String: Schema.Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option.Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.Effect<string, Schema.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),
attributes: Schema.optional<any>(property) attributes: {
Rebuild: optional<S>;
Type: S["Type"];
Encoded: S["Encoded"];
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: S["Iso"];
schema: S;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<any, readonly []>) => Schema.optional<any>;
annotateKey: (annotations: Schema.Annotations.Key<any>) => Schema.optional<any>;
check: (checks_0: Check<any>, ...checks: Array<Check<any>>) => Schema.optional<any>;
rebuild: (ast: Union<any>) => Schema.optional<any>;
make: (input: any, options?: Schema.MakeOptions) => any;
makeOption: (input: any, options?: Schema.MakeOptions) => Option.Option<any>;
makeEffect: (input: any, options?: Schema.MakeOptions) => Effect.Effect<any, Schema.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; <…;
}
attributes: import SchemaSchema.const optional: optionalLambda
;<any>(self: any) => Schema.optional<any>
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(import queueEntryAttributesqueueEntryAttributes),
});