Redacted<S>Schema for values that hide sensitive information from error output and inspection.
Details
If the wrapped schema fails, the issue will be redacted to prevent both the actual value and the schema details from being exposed.
Options:
label: When provided, the schema will behave as follows:- Values will be validated against the label in addition to the wrapped schema
- The default JSON serializer will deserialize into a
Redactedinstance with the label - The arbitrary generator will produce a
Redactedinstance with the label - The formatter will return the label
disallowJsonEncode: When set totrue, when attempting to encode aRedactedinstance into JSON, it will fail with an error. This is useful when the wrapped schema is sensitive and should not be exposed in JSON.
export interface interface Redacted<S extends Constraint>Schema for values that hide sensitive information from error output and
inspection.
Details
If the wrapped schema fails, the issue will be redacted to prevent both
the actual value and the schema details from being exposed.
Options:
label: When provided, the schema will behave as follows:
- Values will be validated against the label in addition to the wrapped schema
- The default JSON serializer will deserialize into a
Redacted instance with the label
- The arbitrary generator will produce a
Redacted instance with the label
- The formatter will return the label
disallowJsonEncode: When set to true, when attempting to encode a Redacted instance
into JSON, it will fail with an error. This is useful when the wrapped schema is
sensitive and should not be exposed in JSON.
Type-level representation returned by
Redacted
.
Redacted<function (type parameter) S in Redacted<S extends Constraint>S extends Constraint> extends
interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<Constraint>, Iso = T>Creates a schema for a parametric type (a generic container such as
Array<A>, Option<A>, etc.) by accepting a list of type-parameter schemas
and a decoder factory.
When to use
Use when you are defining a schema for a generic container whose validation
depends on one or more type-parameter schemas.
Details
The outer call declareConstructor<T, E, Iso>() fixes the decoded type T,
the encoded type E, and the optional iso type. The inner call receives:
typeParameters — the concrete schemas for each type variable
run — a factory that, given resolved codecs for each type parameter,
returns a parsing function (u, ast, options) => Effect<T, Issue>
annotations — optional metadata
Type-level representation returned by
declareConstructor
.
declareConstructor<
import Redacted_Redacted_.type Redacted_.Redacted = /*unresolved*/ anyRedacted<function (type parameter) S in Redacted<S extends Constraint>S["Type"]>,
import Redacted_Redacted_.type Redacted_.Redacted = /*unresolved*/ anyRedacted<function (type parameter) S in Redacted<S extends Constraint>S["Encoded"]>,
readonly [function (type parameter) S in Redacted<S extends Constraint>S]
>
{
readonly "Rebuild": interface Redacted<S extends Constraint>Schema for values that hide sensitive information from error output and
inspection.
Details
If the wrapped schema fails, the issue will be redacted to prevent both
the actual value and the schema details from being exposed.
Options:
label: When provided, the schema will behave as follows:
- Values will be validated against the label in addition to the wrapped schema
- The default JSON serializer will deserialize into a
Redacted instance with the label
- The arbitrary generator will produce a
Redacted instance with the label
- The formatter will return the label
disallowJsonEncode: When set to true, when attempting to encode a Redacted instance
into JSON, it will fail with an error. This is useful when the wrapped schema is
sensitive and should not be exposed in JSON.
Type-level representation returned by
Redacted
.
Redacted<function (type parameter) S in Redacted<S extends Constraint>S>
readonly Redacted<S extends Constraint>.value: S extends Constraintvalue: function (type parameter) S in Redacted<S extends Constraint>S
}
/**
* Schema for values that hide sensitive information from error output and
* inspection.
*
* **Details**
*
* If the wrapped schema fails, the issue will be redacted to prevent both
* the actual value and the schema details from being exposed.
*
* Options:
*
* - `label`: When provided, the schema will behave as follows:
* - Values will be validated against the label in addition to the wrapped schema
* - The default JSON serializer will deserialize into a `Redacted` instance with the label
* - The arbitrary generator will produce a `Redacted` instance with the label
* - The formatter will return the label
* - `disallowJsonEncode`: When set to `true`, when attempting to encode a `Redacted` instance
* into JSON, it will fail with an error. This is useful when the wrapped schema is
* sensitive and should not be exposed in JSON.
*
* @see {@link RedactedFromValue} for decoding raw values and wrapping them in `Redacted`.
* @category Redacted
* @since 3.10.0
*/
export function function Redacted<S extends Constraint>(
value: S,
options?: {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
): Redacted<S>
Schema for values that hide sensitive information from error output and
inspection.
Details
If the wrapped schema fails, the issue will be redacted to prevent both
the actual value and the schema details from being exposed.
Options:
label: When provided, the schema will behave as follows:
- Values will be validated against the label in addition to the wrapped schema
- The default JSON serializer will deserialize into a
Redacted instance with the label
- The arbitrary generator will produce a
Redacted instance with the label
- The formatter will return the label
disallowJsonEncode: When set to true, when attempting to encode a Redacted instance
into JSON, it will fail with an error. This is useful when the wrapped schema is
sensitive and should not be exposed in JSON.
Redacted<function (type parameter) S in Redacted<S extends Constraint>(value: S, options?: {
readonly label?: string | undefined;
readonly disallowJsonEncode?: boolean | undefined;
}): Redacted<S>
S extends Constraint>(value: S extends Constraintvalue: function (type parameter) S in Redacted<S extends Constraint>(value: S, options?: {
readonly label?: string | undefined;
readonly disallowJsonEncode?: boolean | undefined;
}): Redacted<S>
S, options: | {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
| undefined
options?: {
readonly label?: string | undefinedlabel?: string | undefined
readonly disallowJsonEncode?: boolean | undefineddisallowJsonEncode?: boolean | undefined
}): interface Redacted<S extends Constraint>Schema for values that hide sensitive information from error output and
inspection.
Details
If the wrapped schema fails, the issue will be redacted to prevent both
the actual value and the schema details from being exposed.
Options:
label: When provided, the schema will behave as follows:
- Values will be validated against the label in addition to the wrapped schema
- The default JSON serializer will deserialize into a
Redacted instance with the label
- The arbitrary generator will produce a
Redacted instance with the label
- The formatter will return the label
disallowJsonEncode: When set to true, when attempting to encode a Redacted instance
into JSON, it will fail with an error. This is useful when the wrapped schema is
sensitive and should not be exposed in JSON.
Type-level representation returned by
Redacted
.
Redacted<function (type parameter) S in Redacted<S extends Constraint>(value: S, options?: {
readonly label?: string | undefined;
readonly disallowJsonEncode?: boolean | undefined;
}): Redacted<S>
S> {
const const decodeLabel:
| ((
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
string,
SchemaIssue.Issue,
never
>)
| undefined
decodeLabel = typeof options: | {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
| undefined
options?.label?: string | undefinedlabel === "string"
? import SchemaParserSchemaParser.function decodeUnknownEffect<
S extends Schema.Constraint
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Type"],
SchemaIssue.Issue,
S["DecodingServices"]
>
Creates an effectful decoder for unknown input.
When to use
Use when you need to decode untyped boundary input in an Effect whose
failure channel is SchemaIssue.Issue, while preserving transformations
and service requirements.
Details
The returned function succeeds with the schema's decoded Type or fails with a
SchemaIssue.Issue. Decoding service requirements are preserved in the returned
Effect. Parse options may be provided when creating the decoder and overridden
when applying it.
decodeUnknownEffect(function Literal<
L extends SchemaAST.LiteralValue
>(literal: L): Literal<L>
Creates a schema for a single literal value (string, number, bigint, boolean, or null).
Example (Defining a string literal)
import { Schema } from "effect"
const schema = Schema.Literal("hello")
// Type: Schema.Literal<"hello">
Literal(options: {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
options.label?: stringlabel))
: var undefinedundefined
const const schema: declareConstructor<
Redacted_.Redacted<S["Type"]>,
Redacted_.Redacted<S["Encoded"]>,
readonly [S],
Redacted_.Redacted<S["Type"]>
>
const schema: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<Redacted_.Redacted<S['Type']>, readonly [S]>) => declareConstructor<Redacted_.Redacted<S['Type']>, Redacted_.Redacted<S['Encoded']>, readonly [S], Redacted_.Redacted<S['Type']>>;
annotateKey: (annotations: Annotations.Key<Redacted_.Redacted<S['Type']>>) => declareConstructor<Redacted_.Redacted<S['Type']>, Redacted_.Redacted<S['Encoded']>, readonly [S], Redacted_.Redacted<S['Type']>>;
check: (checks_0: SchemaAST.Check<Redacted_.Redacted<S['Type']>>, ...checks: Array<SchemaAST.Check<Redacted_.Redacted<S['Type']>>>) => declareConstructor<Redacted_.Redacted<S['Type']>, Redacted_.Redacted<S['Encoded']>, readonly [S], Redacted_.Red…;
rebuild: (ast: SchemaAST.Declaration) => declareConstructor<Redacted_.Redacted<S['Type']>, Redacted_.Redacted<S['Encoded']>, readonly [S], Redacted_.Redacted<S['Type']>>;
make: (input: Redacted_.Redacted<S['Type']>, options?: MakeOptions) => Redacted_.Redacted<S['Type']>;
makeOption: (input: Redacted_.Redacted<S['Type']>, options?: MakeOptions) => Option_.Option<Redacted_.Redacted<S['Type']>>;
makeEffect: (input: Redacted_.Redacted<S['Type']>, options?: MakeOptions) => Effect.Effect<Redacted_.Redacted<S['Type']>, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
schema = function declareConstructor<
T,
E = T,
Iso = T
>(): <
TypeParameters extends ReadonlyArray<Constraint>
>(
typeParameters: TypeParameters,
run: (typeParameters: {
readonly [K in keyof TypeParameters]: Codec<
TypeParameters[K]["Type"],
TypeParameters[K]["Encoded"]
>
}) => (
u: unknown,
self: SchemaAST.Declaration,
options: SchemaAST.ParseOptions
) => Effect.Effect<T, SchemaIssue.Issue>,
annotations?: Annotations.Declaration<
T,
TypeParameters
>
) => declareConstructor<T, E, TypeParameters, Iso>
Creates a schema for a parametric type (a generic container such as
Array<A>, Option<A>, etc.) by accepting a list of type-parameter schemas
and a decoder factory.
When to use
Use when you are defining a schema for a generic container whose validation
depends on one or more type-parameter schemas.
Details
The outer call declareConstructor<T, E, Iso>() fixes the decoded type T,
the encoded type E, and the optional iso type. The inner call receives:
typeParameters — the concrete schemas for each type variable
run — a factory that, given resolved codecs for each type parameter,
returns a parsing function (u, ast, options) => Effect<T, Issue>
annotations — optional metadata
declareConstructor<import Redacted_Redacted_.type Redacted_.Redacted = /*unresolved*/ anyRedacted<function (type parameter) S in Redacted<S extends Constraint>(value: S, options?: {
readonly label?: string | undefined;
readonly disallowJsonEncode?: boolean | undefined;
}): Redacted<S>
S["Type"]>, import Redacted_Redacted_.type Redacted_.Redacted = /*unresolved*/ anyRedacted<function (type parameter) S in Redacted<S extends Constraint>(value: S, options?: {
readonly label?: string | undefined;
readonly disallowJsonEncode?: boolean | undefined;
}): Redacted<S>
S["Encoded"]>>()(
[value: S extends Constraintvalue],
([value: Codec<
S["Type"],
S["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<S['Type'], any>) => Codec<S['Type'], S['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<S['Type']>) => Codec<S['Type'], S['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<S['Type']>, ...checks: Array<SchemaAST.Check<S['Type']>>) => Codec<S['Type'], S['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<S['Type'], S['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => S['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<S['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<S['Type'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
value]) => (input: unknowninput, ast: SchemaAST.Declaration(parameter) ast: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, poptions: SchemaAST.ParseOptions(parameter) poptions: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
poptions) => {
if (import Redacted_Redacted_.isRedacted(input: unknowninput)) {
const const label: Effect.Effect<
void,
SchemaIssue.Issue,
never
>
const label: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
label: import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<void, import SchemaIssueSchemaIssue.type Issue =
| SchemaIssue.Leaf
| SchemaIssue.Filter
| SchemaIssue.Encoding
| SchemaIssue.Pointer
| SchemaIssue.Composite
| SchemaIssue.AnyOf
The root discriminated union of all validation error nodes.
When to use
Use when typing the error channel in Effect<A, Issue, R> results from
schema parsing, or when writing custom formatters or issue-tree walkers.
Details
Every node has a _tag field for pattern-matching. The union includes both
terminal
Leaf
types and composite types that wrap inner issues:
Filter
,
Encoding
,
Pointer
,
Composite
,
AnyOf
. All Issue instances have a toString() that delegates to
the default formatter, so String(issue) produces a human-readable message.
Issue, never> = const decodeLabel:
| ((
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
string,
SchemaIssue.Issue,
never
>)
| undefined
decodeLabel !== var undefinedundefined
? import EffectEffect.mapErrorEager(
const decodeLabel: (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
string,
SchemaIssue.Issue,
never
>
decodeLabel(input: Redacted_.Redacted<unknown>(parameter) input: {
label: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
input.label, poptions: SchemaAST.ParseOptions(parameter) poptions: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
poptions),
(issue: SchemaIssue.Issueissue) => new import SchemaIssueSchemaIssue.constructor Pointer(path: ReadonlyArray<PropertyKey>, issue: SchemaIssue.Issue): SchemaIssue.PointerWraps an inner
Issue
with a property-key path, indicating where in
a nested structure the error occurred.
When to use
Use when you need to walk the issue tree to accumulate path segments for error
reporting.
Details
path is an array of property keys (strings, numbers, or symbols).
- Has no
actual value —
getActual
returns Option.none().
- Formatters concatenate nested
Pointer paths into a single path like
["a"]["b"][0].
Pointer(["label"], issue: SchemaIssue.Issueissue)
)
: import EffectEffect.void
return import EffectEffect.flatMapEager(
const label: Effect.Effect<
void,
SchemaIssue.Issue,
never
>
const label: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
label,
() =>
import EffectEffect.mapBothEager(
import SchemaParserSchemaParser.function decodeUnknownEffect<
S extends Schema.Constraint
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Type"],
SchemaIssue.Issue,
S["DecodingServices"]
>
Creates an effectful decoder for unknown input.
When to use
Use when you need to decode untyped boundary input in an Effect whose
failure channel is SchemaIssue.Issue, while preserving transformations
and service requirements.
Details
The returned function succeeds with the schema's decoded Type or fails with a
SchemaIssue.Issue. Decoding service requirements are preserved in the returned
Effect. Parse options may be provided when creating the decoder and overridden
when applying it.
decodeUnknownEffect(value: Codec<
S["Type"],
S["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<S['Type'], any>) => Codec<S['Type'], S['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<S['Type']>) => Codec<S['Type'], S['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<S['Type']>, ...checks: Array<SchemaAST.Check<S['Type']>>) => Codec<S['Type'], S['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<S['Type'], S['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => S['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<S['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<S['Type'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
value)(import Redacted_Redacted_.value(input: Redacted_.Redacted<unknown>(parameter) input: {
label: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
input), poptions: SchemaAST.ParseOptions(parameter) poptions: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
poptions),
{
onSuccess: () => unknownonSuccess: () => input: Redacted_.Redacted<unknown>(parameter) input: {
label: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
input,
onFailure: () => SchemaIssue.CompositeonFailure: (/** ignore the actual issue because of security reasons */) => {
const const oinput: Option_.Option<
Redacted_.Redacted<unknown>
>
oinput = import Option_Option_.some(input: Redacted_.Redacted<unknown>(parameter) input: {
label: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
input)
return new import SchemaIssueSchemaIssue.constructor Composite(ast: SchemaAST.AST, actual: StandardJSONSchemaV1<unknown>, issues: readonly [SchemaIssue.Issue, ...Array<SchemaIssue.Issue>]): SchemaIssue.CompositeRepresents a schema issue that groups multiple child issues under a single schema node.
When to use
Use when you need to walk the issue tree for struct/tuple schemas that collect
all field errors rather than failing on the first.
Details
issues is a non-empty readonly array (at least one child).
actual is Option.some(value) when the input was present, or
Option.none() when absent.
- Formatters flatten
Composite by recursing into each child.
Composite(ast: SchemaAST.Declaration(parameter) ast: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, const oinput: Option_.Option<
Redacted_.Redacted<unknown>
>
oinput, [
new import SchemaIssueSchemaIssue.constructor Pointer(path: ReadonlyArray<PropertyKey>, issue: SchemaIssue.Issue): SchemaIssue.PointerWraps an inner
Issue
with a property-key path, indicating where in
a nested structure the error occurred.
When to use
Use when you need to walk the issue tree to accumulate path segments for error
reporting.
Details
path is an array of property keys (strings, numbers, or symbols).
- Has no
actual value —
getActual
returns Option.none().
- Formatters concatenate nested
Pointer paths into a single path like
["a"]["b"][0].
Pointer(["value"], new import SchemaIssueSchemaIssue.constructor InvalidValue(actual: StandardJSONSchemaV1<unknown>, annotations?: Annotations.Issue | undefined): SchemaIssue.InvalidValueRepresents a schema issue produced when the input has the correct type but its value violates a
constraint (e.g. a string that is too short, a number out of range).
When to use
Use when you need to detect constraint violations from Schema.filter,
Schema.minLength, Schema.greaterThan, or similar checks.
Details
actual is Option.some(value) when the failing value is known, or
Option.none() when absent.
annotations optionally carries a message string for formatting.
- The default formatter renders this as
"Invalid data <actual>" unless a
custom message annotation is provided.
Example (Returning InvalidValue from a custom filter)
import { Option, SchemaIssue } from "effect"
const issue = new SchemaIssue.InvalidValue(
Option.some(""),
{ message: "must not be empty" }
)
console.log(String(issue))
// "must not be empty"
InvalidValue(const oinput: Option_.Option<
Redacted_.Redacted<unknown>
>
oinput))
])
}
}
)
)
}
return import EffectEffect.fail(new import SchemaIssueSchemaIssue.constructor InvalidType(ast: SchemaAST.AST, actual: StandardJSONSchemaV1<unknown>): SchemaIssue.InvalidTypeRepresents a schema issue produced when the runtime type of the input does not match the type
expected by the schema (e.g. got null when string was expected).
When to use
Use when you need to detect basic type mismatches, such as a wrong primitive
or null where an object was expected.
Details
ast is the schema node that expected a different type.
actual is Option.some(value) when the input was present, or
Option.none() when no value was provided.
- The default formatter renders this as
"Expected <type>, got <actual>".
Example (Formatting output)
import { Schema } from "effect"
try {
Schema.decodeUnknownSync(Schema.String)(42)
} catch (e) {
if (Schema.isSchemaError(e)) {
console.log(String(e.issue))
// "Expected string, got 42"
}
}
InvalidType(ast: SchemaAST.Declaration(parameter) ast: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, import Option_Option_.some(input: unknowninput)))
},
{
Annotations.Declaration<Redacted_.Redacted<S["Type"]>, readonly [S]>.typeConstructor?: {
readonly [key: string]: unknown;
readonly _tag: string;
} | undefined
typeConstructor: {
_tag: string_tag: "effect/Redacted",
options: | {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
| undefined
options
},
Annotations.Declaration<Redacted_.Redacted<S["Type"]>, readonly [S]>.generation?: {
readonly runtime: string;
readonly Type: string;
readonly Encoded?: string | undefined;
readonly importDeclaration?: string | undefined;
} | undefined
generation: {
runtime: stringruntime: options: | {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
| undefined
options !== var undefinedundefined ? `Schema.Redacted(?, ${import formatformat(options: {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
options)})` : `Schema.Redacted(?)`,
type Type: stringType: `Redacted.Redacted<?>`,
importDeclaration?: string | undefinedimportDeclaration: `import * as Redacted from "effect/Redacted"`
},
Annotations.Augment.expected?: string | undefinedHuman-readable description of what a value is expected to satisfy.
Details
For filter and refinement failures, the default formatter uses
message first, then expected, and finally falls back to <filter>.
Use this to name a failed filter in the default message:
Expected <expected>, got <actual>.
expected: "Redacted",
Annotations.Declaration<Redacted_.Redacted<S["Type"]>, readonly [S]>.toCodecJson?: ((typeParameters: readonly [Codec<S["Encoded"], S["Encoded"], never, never>]) => SchemaAST.Link) | undefinedtoCodecJson: ([value: Codec<
S["Encoded"],
S["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<S['Encoded'], any>) => Codec<S['Encoded'], S['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<S['Encoded']>) => Codec<S['Encoded'], S['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<S['Encoded']>, ...checks: Array<SchemaAST.Check<S['Encoded']>>) => Codec<S['Encoded'], S['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<S['Encoded'], S['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => S['Encoded'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<S['Encoded']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<S['Encoded'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
value]) =>
function link<T>(): <
To extends Constraint
>(
encodeTo: To,
transformation: {
readonly decode: SchemaGetter.Getter<
T,
NoInfer<To["Type"]>
>
readonly encode: SchemaGetter.Getter<
NoInfer<To["Type"]>,
T
>
}
) => SchemaAST.Link
Constructs an SchemaAST.Link that describes how a value of type T encodes to and decodes from a To schema.
Used when building low-level AST transformations that bridge two schema types.
link<import Redacted_Redacted_.type Redacted_.Redacted = /*unresolved*/ anyRedacted<function (type parameter) S in Redacted<S extends Constraint>(value: S, options?: {
readonly label?: string | undefined;
readonly disallowJsonEncode?: boolean | undefined;
}): Redacted<S>
S["Encoded"]>>()(
function redact<S extends Constraint>(
schema: S
): middlewareDecoding<S, S["DecodingServices"]>
Middleware that wraps decoded errors in Redacted, preventing sensitive
schema details from leaking in error messages.
redact(value: Codec<
S["Encoded"],
S["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<S['Encoded'], any>) => Codec<S['Encoded'], S['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<S['Encoded']>) => Codec<S['Encoded'], S['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<S['Encoded']>, ...checks: Array<SchemaAST.Check<S['Encoded']>>) => Codec<S['Encoded'], S['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<S['Encoded'], S['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => S['Encoded'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<S['Encoded']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<S['Encoded'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
value),
{
decode: SchemaGetter.Getter<
Redacted_.Redacted<S["Encoded"]>,
NoInfer<S["Encoded"]>,
never
>
(property) decode: {
run: (input: Option.Option<E>, options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>;
map: (f: (t: Redacted_.Redacted<S['Encoded']>) => T2) => SchemaGetter.Getter<T2, NoInfer<S['Encoded']>, never>;
compose: (other: SchemaGetter.Getter<T2, Redacted_.Redacted<S['Encoded']>, R2>) => SchemaGetter.Getter<T2, NoInfer<S['Encoded']>, R2>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
decode: import SchemaGetterSchemaGetter.function transform<T, E>(
f: (e: E) => T
): Getter<T, E>
Creates a getter that applies a pure function to present values.
When to use
Use when you need a schema getter for a pure, infallible transformation
between types.
- Building encode/decode pairs for
Schema.decodeTo.
Details
- This is the most commonly used constructor.
- Transforms
Some(e) to Some(f(e)) and leaves None unchanged.
- Skips
None inputs — only called when a value is present.
- Never fails.
Example (Transforming strings to numbers)
import { Schema, SchemaGetter } from "effect"
const NumberFromString = Schema.String.pipe(
Schema.decodeTo(Schema.Number, {
decode: SchemaGetter.transform((s) => Number(s)),
encode: SchemaGetter.transform((n) => String(n))
})
)
transform((e: NoInfer<S["Encoded"]>e) => import Redacted_Redacted_.make(e: S["Encoded"]e, { label: string | undefinedlabel: options: | {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
| undefined
options?.label?: string | undefinedlabel })),
encode: SchemaGetter.Getter<
NoInfer<S["Encoded"]>,
Redacted_.Redacted<S["Encoded"]>,
never
>
(property) encode: {
run: (input: Option.Option<E>, options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>;
map: (f: (t: NoInfer<S['Encoded']>) => T2) => SchemaGetter.Getter<T2, Redacted_.Redacted<S['Encoded']>, never>;
compose: (other: SchemaGetter.Getter<T2, NoInfer<S['Encoded']>, R2>) => SchemaGetter.Getter<T2, Redacted_.Redacted<S['Encoded']>, R2>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
encode: options: | {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
| undefined
options?.disallowJsonEncode?: boolean | undefineddisallowJsonEncode ?
import SchemaGetterSchemaGetter.function forbidden<T, E>(
message: (oe: Option.Option<E>) => string
): Getter<T, E>
Creates a getter that always fails with a Forbidden issue.
When to use
Use when you need a schema getter to disallow a field or direction
(encode/decode) entirely.
- You want a clear "forbidden" error message in schema validation output.
Details
- Always fails with
SchemaIssue.Forbidden.
- The message function receives the
Option<E> input for context.
Example (Forbidding a decode direction)
import { SchemaGetter } from "effect"
const noEncode = SchemaGetter.forbidden<string, number>(
() => "encoding is not supported"
)
forbidden((oe: Option_.Option<
Redacted_.Redacted<S["Encoded"]>
>
oe) =>
"Cannot serialize Redacted" +
(import Option_Option_.isSome(oe: Option_.Option<
Redacted_.Redacted<S["Encoded"]>
>
oe) && typeof oe: Option_.Some<
Redacted_.Redacted<S["Encoded"]>
>
(parameter) oe: {
_tag: "Some";
_op: "Some";
value: A;
valueOrUndefined: A;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
oe.value.label === "string" ? ` with label: "${oe: Option_.Some<
Redacted_.Redacted<S["Encoded"]>
>
(parameter) oe: {
_tag: "Some";
_op: "Some";
value: A;
valueOrUndefined: A;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
oe.value.label}"` : "")
) :
import SchemaGetterSchemaGetter.function transform<T, E>(
f: (e: E) => T
): Getter<T, E>
Creates a getter that applies a pure function to present values.
When to use
Use when you need a schema getter for a pure, infallible transformation
between types.
- Building encode/decode pairs for
Schema.decodeTo.
Details
- This is the most commonly used constructor.
- Transforms
Some(e) to Some(f(e)) and leaves None unchanged.
- Skips
None inputs — only called when a value is present.
- Never fails.
Example (Transforming strings to numbers)
import { Schema, SchemaGetter } from "effect"
const NumberFromString = Schema.String.pipe(
Schema.decodeTo(Schema.Number, {
decode: SchemaGetter.transform((s) => Number(s)),
encode: SchemaGetter.transform((n) => String(n))
})
)
transform(import Redacted_Redacted_.value)
}
),
Annotations.Declaration<Redacted_.Redacted<S["Type"]>, readonly [S]>.toArbitrary?: Annotations.ToArbitrary.Declaration<Redacted_.Redacted<S["Type"]>, readonly [S]> | undefinedtoArbitrary: ([value: Annotations.ToArbitrary.TypeParameter<
S["Type"]
>
(parameter) value: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
value]) => () => ({
arbitrary: anyarbitrary: value: Annotations.ToArbitrary.TypeParameter<
S["Type"]
>
(parameter) value: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
value.Annotations.ToArbitrary.TypeParameter<T>.arbitrary: FastCheck.Arbitrary<T>arbitrary.map((a: anya) => import Redacted_Redacted_.make(a: anya, { label: string | undefinedlabel: options: | {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
| undefined
options?.label?: string | undefinedlabel })),
terminal: anyterminal: value: Annotations.ToArbitrary.TypeParameter<
S["Type"]
>
(parameter) value: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
value.Annotations.ToArbitrary.TypeParameter<T>.terminal: anyterminal?.map((a: anya) => import Redacted_Redacted_.make(a: anya, { label: string | undefinedlabel: options: | {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
| undefined
options?.label?: string | undefinedlabel }))
}),
Annotations.Declaration<Redacted_.Redacted<S["Type"]>, readonly [S]>.toFormatter?: Annotations.ToFormatter.Declaration<Redacted_.Redacted<S["Type"]>, readonly [S]> | undefinedtoFormatter: () => module globalThisglobalThis.var String: StringConstructorAllows manipulation and formatting of text strings and determination and location of substrings within strings.
String,
Annotations.Declaration<Redacted_.Redacted<S["Type"]>, readonly [S]>.toEquivalence?: Annotations.ToEquivalence.Declaration<Redacted_.Redacted<S["Type"]>, readonly [S]> | undefinedtoEquivalence: ([value: Equivalence.Equivalence<S["Type"]>value]) => import Redacted_Redacted_.makeEquivalence(value: Equivalence.Equivalence<S["Type"]>value)
}
)
return const make: <S extends Constraint>(
ast: S["ast"],
options?: object
) => S
Creates a schema from an AST (Abstract Syntax Tree) node.
Details
This is the fundamental constructor for all schemas in the Effect Schema
library. It takes an AST node and wraps it in a fully-typed schema that
preserves all type information and provides the complete schema API.
The make function is used internally to create all primitive schemas like
String, Number, Boolean, etc., as well as more complex schemas. It's
the bridge between the untyped AST representation and the strongly-typed
schema.
make(const schema: declareConstructor<
Redacted_.Redacted<S["Type"]>,
Redacted_.Redacted<S["Encoded"]>,
readonly [S],
Redacted_.Redacted<S["Type"]>
>
const schema: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<Redacted_.Redacted<S['Type']>, readonly [S]>) => declareConstructor<Redacted_.Redacted<S['Type']>, Redacted_.Redacted<S['Encoded']>, readonly [S], Redacted_.Redacted<S['Type']>>;
annotateKey: (annotations: Annotations.Key<Redacted_.Redacted<S['Type']>>) => declareConstructor<Redacted_.Redacted<S['Type']>, Redacted_.Redacted<S['Encoded']>, readonly [S], Redacted_.Redacted<S['Type']>>;
check: (checks_0: SchemaAST.Check<Redacted_.Redacted<S['Type']>>, ...checks: Array<SchemaAST.Check<Redacted_.Redacted<S['Type']>>>) => declareConstructor<Redacted_.Redacted<S['Type']>, Redacted_.Redacted<S['Encoded']>, readonly [S], Redacted_.Red…;
rebuild: (ast: SchemaAST.Declaration) => declareConstructor<Redacted_.Redacted<S['Type']>, Redacted_.Redacted<S['Encoded']>, readonly [S], Redacted_.Redacted<S['Type']>>;
make: (input: Redacted_.Redacted<S['Type']>, options?: MakeOptions) => Redacted_.Redacted<S['Type']>;
makeOption: (input: Redacted_.Redacted<S['Type']>, options?: MakeOptions) => Option_.Option<Redacted_.Redacted<S['Type']>>;
makeEffect: (input: Redacted_.Redacted<S['Type']>, options?: MakeOptions) => Effect.Effect<Redacted_.Redacted<S['Type']>, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
schema.Bottom<Redacted_.Redacted<S["Type"]>, Redacted_.Redacted<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"], Declaration, declareConstructor<Redacted_.Redacted<S["Type"]>, Redacted_.Redacted<S["Encoded"]>, readonly [S], Redacted_.Redacted<...>>, ... 8 more ..., "required">["ast"]: SchemaAST.Declaration(property) Bottom<Redacted_.Redacted<S["Type"]>, Redacted_.Redacted<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"], Declaration, declareConstructor<Redacted_.Redacted<S["Type"]>, Redacted_.Redacted<S["Encoded"]>, readonly [S], Redacted_.Redacted<...>>, ... 8 more ..., "required">["ast"]: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, { value: S extends Constraintvalue })
}