function / @typed/guard

fromSchemaEncode

Creates a Guard that encodes a schema’s Type to its Encoded representation.

Package version
1.0.0-beta.13
Category
Schema decoding and encoding
Since
1.0.0

Import

import { fromSchemaEncode } from "@typed/guard";

Signatures

export declare function fromSchemaEncode<S extends Schema.Top>(schema: S): Guard<S["Type"], S["Encoded"], Schema.SchemaError, S["EncodingServices"]>;

Why

Schema encoding is the reverse direction of decoding and keeps encoding services and SchemaError visible in the Guard type.

Ownership and lifetime

Construction acquires no resources; schema services and any scoped work follow each returned Effect invocation.

Examples

import { fromSchemaEncode } from "@typed/guard"
import { Schema } from "effect"
const encoded = fromSchemaEncode(Schema.NumberFromString)

Source