<S extends Schema.Constraint>(schema: S): <
IE = never,
Done = unknown
>() => Channel.Channel<
Arr.NonEmptyReadonlyArray<unknown>,
IE | Schema.SchemaError,
Done,
Arr.NonEmptyReadonlyArray<S["Type"]>,
IE,
Done,
S["EncodingServices"]
>Creates an encode channel variant whose encoded output chunks are typed as
unknown.
When to use
Use when a channel boundary should encode typed input chunks while the encoded output representation is intentionally untyped.
export const const encodeUnknown: <
S extends Schema.Constraint
>(
schema: S
) => <
IE = never,
Done = unknown
>() => Channel.Channel<
Arr.NonEmptyReadonlyArray<unknown>,
IE | Schema.SchemaError,
Done,
Arr.NonEmptyReadonlyArray<S["Type"]>,
IE,
Done,
S["EncodingServices"]
>
Creates an encode channel variant whose encoded output chunks are typed as
unknown.
When to use
Use when a channel boundary should encode typed input chunks while the encoded
output representation is intentionally untyped.
encodeUnknown: <function (type parameter) S in <S extends Schema.Constraint>(schema: S): <IE = never, Done = unknown>() => Channel.Channel<Arr.NonEmptyReadonlyArray<unknown>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Type"]>, IE, Done, S["EncodingServices"]>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<unknown>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Type"]>, IE, Done, S["EncodingServices"]>S
) => <function (type parameter) IE in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<unknown>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Type"]>, IE, Done, S["EncodingServices"]>IE = never, function (type parameter) Done in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<unknown>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Type"]>, IE, Done, S["EncodingServices"]>Done = unknown>() => import ChannelChannel.type Channel.Channel = /*unresolved*/ anyChannel<
import ArrArr.type Arr.NonEmptyReadonlyArray = /*unresolved*/ anyNonEmptyReadonlyArray<unknown>,
function (type parameter) IE in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<unknown>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Type"]>, IE, Done, S["EncodingServices"]>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<unknown>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Type"]>, IE, Done, S["EncodingServices"]>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<unknown>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Type"]>, IE, Done, S["EncodingServices"]>S["Type"]>,
function (type parameter) IE in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<unknown>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Type"]>, IE, Done, S["EncodingServices"]>IE,
function (type parameter) Done in <IE = never, Done = unknown>(): Channel.Channel<Arr.NonEmptyReadonlyArray<unknown>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Type"]>, IE, Done, S["EncodingServices"]>Done,
function (type parameter) S in <S extends Schema.Constraint>(schema: S): <IE = never, Done = unknown>() => Channel.Channel<Arr.NonEmptyReadonlyArray<unknown>, IE | Schema.SchemaError, Done, Arr.NonEmptyReadonlyArray<S["Type"]>, IE, Done, S["EncodingServices"]>S["EncodingServices"]
> = const encode: <
S extends Schema.Constraint
>(
schema: S
) => <
IE = never,
Done = unknown
>() => Channel.Channel<
Arr.NonEmptyReadonlyArray<S["Encoded"]>,
IE | Schema.SchemaError,
Done,
Arr.NonEmptyReadonlyArray<S["Type"]>,
IE,
Done,
S["EncodingServices"]
>
Creates a channel that encodes non-empty chunks of schema values into the
schema's encoded representation.
When to use
Use to encode typed channel input into the schema's encoded representation
before passing chunks to an encoded downstream boundary.
Details
Encoding failures are emitted as SchemaError, and any encoding services
required by the schema become channel requirements.
encode