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.function decodeFormData(): Getter<
Schema.TreeRecord<string | Blob>,
FormData
>
Decodes a FormData object into a nested tree structure using bracket-path notation.
When to use
Use when you need a schema getter to parse FormData from HTTP requests into
structured objects.
Details
The getter is pure and never fails. It interprets bracket-path keys such as
user[name] and items[0] to build nested objects or arrays, and each leaf
value is a string or Blob.
Example (Decoding FormData)
import { SchemaGetter } from "effect"
const decode = SchemaGetter.decodeFormData()
// Getter<TreeObject<string | Blob>, FormData>
decodeFormData(),
import SchemaGetterSchemaGetter.function encodeFormData(): Getter<
FormData,
unknown
>
Encodes a nested object into a FormData instance using bracket-path notation.
When to use
Use when you need a schema getter to serialize structured data to FormData
for HTTP requests.
Details
The getter is pure and never fails. It flattens nested objects or arrays into
bracket-path keys such as user[name] and items[0]. Non-object inputs
produce an empty FormData.
Example (Encoding to FormData)
import { SchemaGetter } from "effect"
const encode = SchemaGetter.encodeFormData()
// Getter<FormData, unknown>
encodeFormData()
)