Transformation<unknown, FormData, never, never>Decodes a FormData instance into a nested record using bracket-path keys and
encodes object-like values back into FormData.
When to use
Use when you need a schema transformation for form or multipart payloads
whose keys, such as user[name] or items[0], should become nested data.
Details
Decode preserves string and Blob leaves. Encode flattens nested objects and
arrays into bracket-path entries and returns an empty FormData for
non-object inputs.
Example (Decoding FormData)
import { Schema, SchemaTransformation } from "effect"
const schema = Schema.instanceOf(FormData).pipe(
Schema.decodeTo(Schema.Unknown, SchemaTransformation.fromFormData)
)export const const fromFormData: Transformation<
unknown,
FormData,
never,
never
>
const fromFormData: {
_tag: 'Transformation';
decode: SchemaGetter.Getter<T, E, RD>;
encode: SchemaGetter.Getter<E, T, RE>;
flip: () => Transformation<FormData, unknown, never, never>;
compose: (other: Transformation<T2, unknown, RD2, RE2>) => Transformation<T2, FormData, RD2, RE2>;
}
Decodes a FormData instance into a nested record using bracket-path keys and
encodes object-like values back into FormData.
When to use
Use when you need a schema transformation for form or multipart payloads
whose keys, such as user[name] or items[0], should become nested data.
Details
Decode preserves string and Blob leaves. Encode flattens nested objects and
arrays into bracket-path entries and returns an empty FormData for
non-object inputs.
Example (Decoding FormData)
import { Schema, SchemaTransformation } from "effect"
const schema = Schema.instanceOf(FormData).pipe(
Schema.decodeTo(Schema.Unknown, SchemaTransformation.fromFormData)
)
fromFormData = new constructor Transformation<unknown, FormData, never, never>(decode: SchemaGetter.Getter<unknown, FormData, never>, encode: SchemaGetter.Getter<FormData, unknown, never>): Transformation<unknown, FormData, 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<unknown, FormData>(
import SchemaGetterSchemaGetter.decodeFormData(),
import SchemaGetterSchemaGetter.encodeFormData()
)