function / @typed/guard

fromSchemaDecode

Creates a Guard that decodes a schema’s Encoded input to its Type.

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

Import

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

Signatures

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

Why

Schema decoding reports all issues, ignores excess properties, retains SchemaError in the typed channel, and carries decoding services in R.

Ownership and lifetime

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

Examples

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

See Effect Schema transformations.

Source