effect-io-ai

Package: effect
Module: SchemaTransformation

SchemaTransformation.Transformation

Represents a bidirectional transformation between a decoded type T and an encoded type E, built from a pair of Getters.

When to use

Use when you need a schema transformation that defines how a schema converts between two representations.

Details

This is the primary building block for Schema.decodeTo, Schema.encodeTo, Schema.decode, Schema.encode, and Schema.link. Each direction is a SchemaGetter.Getter that handles optionality, failure, and Effect services.

Example (Composing two transformations)

import { SchemaTransformation } from "effect"

const trimAndLower = SchemaTransformation.trim().compose(
  SchemaTransformation.toLowerCase()
)
// decode: trim then lowercase
// encode: passthrough (both directions)

See

Signature

declare class Transformation<T, E, RD, RE> { constructor(
    decode: SchemaGetter.Getter<T, E, RD>,
    encode: SchemaGetter.Getter<E, T, RE>
  ) }

Source

Since v4.0.0