Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.passthroughfunctioneffect/SchemaTransformation.ts:705
<T, E>(options: { readonly strict: false }): Transformation<T, E>
<T>(): Transformation<T, T>

Transforms values by returning the input unchanged in both directions.

When to use

Use when you need a schema transformation to connect two schemas that share the same type with no actual conversion.

Details

  • Both decode and encode are no-ops.
  • Returns a shared singleton instance (no allocation per call).
  • By default, T and E must be the same type. Pass { strict: false } to bypass the type constraint.

Example (Chaining schemas with no conversion)

import { Schema, SchemaTransformation } from "effect"

const schema = Schema.Trim.pipe(
  Schema.decodeTo(Schema.FiniteFromString, SchemaTransformation.passthrough())
)
export function passthrough<T, E>(options: { readonly strict: false }): Transformation<T, E>
export function passthrough<T>(): Transformation<T, T>
export function passthrough<T>(): Transformation<T, T> {
  return passthrough_
}
Referenced by 1 symbols