<S extends Schema.Constraint>(schema: S): <
IE = never,
Done = unknown
>() => Channel.Channel<
Arr.NonEmptyReadonlyArray<S["Type"]>,
IE | Schema.SchemaError,
Done,
Arr.NonEmptyReadonlyArray<S["Encoded"]>,
IE,
Done,
S["DecodingServices"]
>Creates a decode channel variant for schema-decoding channel boundaries.
When to use
Use when you need an intentionally unknown or untyped encoded input while keeping only the decoded output statically typed according to the schema.
Details
The channel decodes non-empty encoded chunks into schema values, emits
SchemaError when decoding fails, and requires the schema's decoding
services.
export const const decodeUnknown: <
S extends Schema.Constraint
>(
schema: S
) => <
IE = never,
Done = unknown
>() => Channel.Channel<
Arr.NonEmptyReadonlyArray<S["Type"]>,
IE | Schema.SchemaError,
Done,
Arr.NonEmptyReadonlyArray<S["Encoded"]>,
IE,
Done,
S["DecodingServices"]
>
Creates a decode channel variant for schema-decoding channel boundaries.
When to use
Use when you need an intentionally unknown or untyped encoded input while
keeping only the decoded output statically typed according to the schema.
Details
The channel decodes non-empty encoded chunks into schema values, emits
SchemaError when decoding fails, and requires the schema's decoding
services.
decodeUnknown: <function (type parameter) S in <S extends Schema.Constraint>(schema: S): <IE = never, Done = unknown>() => Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>S extends import SchemaSchema.Constraint>(
schema: S extends Schema.Constraintschema: function (type parameter) S in <S extends Schema.Constraint>(schema: S): <IE = never, Done = unknown>() => Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>S
) => <function (type parameter) IE in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>IE = never, function (type parameter) Done in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>Done = unknown>() => import ChannelChannel.type Channel.Channel = /*unresolved*/ anyChannel<
import ArrArr.type Arr.NonEmptyReadonlyArray = /*unresolved*/ anyNonEmptyReadonlyArray<function (type parameter) S in <S extends Schema.Constraint>(schema: S): <IE = never, Done = unknown>() => Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>S["Type"]>,
function (type parameter) IE in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>IE | import SchemaSchema.class SchemaError
export SchemaError
class SchemaError {
message: string;
toString: () => string;
name: string;
stack: string;
cause: unknown;
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; <…;
toJSON: () => unknown;
_tag: Tag;
issue: Issue;
}
Error thrown (or returned as the error channel value) when schema decoding
or encoding fails.
Details
The issue field contains a structured
SchemaIssue.Issue
tree describing
every validation failure, including the path to the problematic value,
expected types, and actual values received. message renders the issue tree
as a human-readable string.
Use
isSchemaError
to narrow an unknown value to SchemaError.
Example (Catching a SchemaError)
import { Schema } from "effect"
try {
Schema.decodeUnknownSync(Schema.Number)("not a number")
} catch (err) {
if (Schema.isSchemaError(err)) {
console.log(err.message)
// Expected number, actual "not a number"
}
}
SchemaError,
function (type parameter) Done in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>Done,
import ArrArr.type Arr.NonEmptyReadonlyArray = /*unresolved*/ anyNonEmptyReadonlyArray<function (type parameter) S in <S extends Schema.Constraint>(schema: S): <IE = never, Done = unknown>() => Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>S["Encoded"]>,
function (type parameter) IE in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>IE,
function (type parameter) Done in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>Done,
function (type parameter) S in <S extends Schema.Constraint>(schema: S): <IE = never, Done = unknown>() => Channel.Channel<Arr.NonEmptyReadonlyArray<S["Type"]>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Encoded"]>, IE, Done, S["DecodingServices"]>S["DecodingServices"]
> = const decode: <
S extends Schema.Constraint
>(
schema: S
) => <
IE = never,
Done = unknown
>() => Channel.Channel<
Arr.NonEmptyReadonlyArray<S["Type"]>,
IE | Schema.SchemaError,
Done,
Arr.NonEmptyReadonlyArray<S["Encoded"]>,
IE,
Done,
S["DecodingServices"]
>
Creates a channel that decodes non-empty chunks from the schema's encoded
representation into schema values.
When to use
Use to validate and decode encoded channel output into typed schema values
before application code consumes it.
Details
Decoding failures are emitted as SchemaError, and any decoding services
required by the schema become channel requirements.
decode