(): Transformation<string, string>Transforms strings by lowercasing the first character on decode. Encode is passthrough.
When to use
Use when you need a schema transformation to normalize identifiers or field names.
Details
Decoding lowercases the first character and leaves the rest unchanged. Encoding is passthrough.
Example (Uncapitalizing on decode)
import { Schema, SchemaTransformation } from "effect"
const Uncapitalized = Schema.String.pipe(
Schema.decode(SchemaTransformation.uncapitalize())
)export function function uncapitalize(): Transformation<
string,
string
>
Transforms strings by lowercasing the first character on
decode. Encode is passthrough.
When to use
Use when you need a schema transformation to normalize identifiers or field
names.
Details
Decoding lowercases the first character and leaves the rest unchanged.
Encoding is passthrough.
Example (Uncapitalizing on decode)
import { Schema, SchemaTransformation } from "effect"
const Uncapitalized = Schema.String.pipe(
Schema.decode(SchemaTransformation.uncapitalize())
)
uncapitalize(): class Transformation<in out T, in out E, RD = never, RE = never>class Transformation {
_tag: 'Transformation';
decode: SchemaGetter.Getter<T, E, RD>;
encode: SchemaGetter.Getter<E, T, RE>;
flip: () => Transformation<E, T, RE, RD>;
compose: <T2, RD2, RE2>(other: Transformation<T2, T, RD2, RE2>) => Transformation<T2, E, RD | RD2, RE | RE2>;
}
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.
- You want to compose multiple transformations into a pipeline.
- You want to flip a transformation to swap decode/encode.
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.
- Immutable —
flip() and compose() return new instances.
flip() swaps the decode and encode getters.
compose(other) chains: this.decode then other.decode for decoding,
other.encode then this.encode for encoding.
Example (Composing two transformations)
import { SchemaTransformation } from "effect"
const trimAndLower = SchemaTransformation.trim().compose(
SchemaTransformation.toLowerCase()
)
// decode: trim then lowercase
// encode: passthrough (both directions)
Transformation<string, string> {
return new constructor Transformation<string, string, never, never>(decode: SchemaGetter.Getter<string, string, never>, encode: SchemaGetter.Getter<string, string, never>): Transformation<string, string, never, never>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.
- You want to compose multiple transformations into a pipeline.
- You want to flip a transformation to swap decode/encode.
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.
- Immutable —
flip() and compose() return new instances.
flip() swaps the decode and encode getters.
compose(other) chains: this.decode then other.decode for decoding,
other.encode then this.encode for encoding.
Example (Composing two transformations)
import { SchemaTransformation } from "effect"
const trimAndLower = SchemaTransformation.trim().compose(
SchemaTransformation.toLowerCase()
)
// decode: trim then lowercase
// encode: passthrough (both directions)
Transformation(
import SchemaGetterSchemaGetter.function uncapitalize<
E extends string
>(): Getter<string, E>
Uncapitalizes the first character of a string.
Details
- Pure, delegates to
String.uncapitalize.
Example (Uncapitalizing a string)
import { SchemaGetter } from "effect"
const uncap = SchemaGetter.uncapitalize<string>()
uncapitalize(),
import SchemaGetterSchemaGetter.function passthrough<string>(): SchemaGetter.Getter<string, string, never> (+1 overload)Returns the identity getter — passes the value through unchanged.
When to use
Use when you need a schema getter for one side of a decodeTo pair, either
encode or decode, to pass values through unchanged.
Details
- Pure, no allocation (singleton instance).
- Optimized away during
.compose() — composing with a passthrough is free.
- The default overload requires
T === E. Pass { strict: false } to opt
out of the type constraint.
Example (Passing through identity transformations)
import { Schema, SchemaGetter } from "effect"
// No transformation needed — types already match
const StringToString = Schema.String.pipe(
Schema.decodeTo(Schema.String, {
decode: SchemaGetter.passthrough(),
encode: SchemaGetter.passthrough()
})
)
passthrough()
)
}