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_.interface Redacted<out A = string>A wrapper for sensitive values whose string, JSON, and inspection output is
redacted.
When to use
Use to carry sensitive values while reducing accidental exposure in string,
JSON, and inspection output.
Gotchas
The underlying value is still stored in memory and can be recovered with
Redacted.value until the wrapper is wiped or becomes unreachable. Use
Redacted to reduce accidental disclosure in logs and diagnostics, not as a
cryptographic protection mechanism.
Example (Creating redacted values)
import { Redacted } from "effect"
// Create a redacted value to protect sensitive information
const apiKey = Redacted.make("secret-key")
const userPassword = Redacted.make("user-password")
// TypeScript will infer the types as Redacted<string>
Namespace containing type-level members associated with Redacted values.
When to use
Use to access type-level helpers associated with Redacted.
Example (Using namespace utilities)
import { Redacted } from "effect"
// Use the Redacted namespace for type-level operations
const secret = Redacted.make("my-secret")
// The namespace contains utilities for working with Redacted values
const isRedacted = Redacted.isRedacted(secret) // true
Redacted<function (type parameter) S in Redacted<S extends Constraint>S["Type"]>,
import Redacted_Redacted_.interface Redacted<out A = string>A wrapper for sensitive values whose string, JSON, and inspection output is
redacted.
When to use
Use to carry sensitive values while reducing accidental exposure in string,
JSON, and inspection output.
Gotchas
The underlying value is still stored in memory and can be recovered with
Redacted.value until the wrapper is wiped or becomes unreachable. Use
Redacted to reduce accidental disclosure in logs and diagnostics, not as a
cryptographic protection mechanism.
Example (Creating redacted values)
import { Redacted } from "effect"
// Create a redacted value to protect sensitive information
const apiKey = Redacted.make("secret-key")
const userPassword = Redacted.make("user-password")
// TypeScript will infer the types as Redacted<string>
Namespace containing type-level members associated with Redacted values.
When to use
Use to access type-level helpers associated with Redacted.
Example (Using namespace utilities)
import { Redacted } from "effect"
// Use the Redacted namespace for type-level operations
const secret = Redacted.make("my-secret")
// The namespace contains utilities for working with Redacted values
const isRedacted = Redacted.isRedacted(secret) // true
Redacted<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_.interface Redacted<out A = string>A wrapper for sensitive values whose string, JSON, and inspection output is
redacted.
When to use
Use to carry sensitive values while reducing accidental exposure in string,
JSON, and inspection output.
Gotchas
The underlying value is still stored in memory and can be recovered with
Redacted.value until the wrapper is wiped or becomes unreachable. Use
Redacted to reduce accidental disclosure in logs and diagnostics, not as a
cryptographic protection mechanism.
Example (Creating redacted values)
import { Redacted } from "effect"
// Create a redacted value to protect sensitive information
const apiKey = Redacted.make("secret-key")
const userPassword = Redacted.make("user-password")
// TypeScript will infer the types as Redacted<string>
Namespace containing type-level members associated with Redacted values.
When to use
Use to access type-level helpers associated with Redacted.
Example (Using namespace utilities)
import { Redacted } from "effect"
// Use the Redacted namespace for type-level operations
const secret = Redacted.make("my-secret")
// The namespace contains utilities for working with Redacted values
const isRedacted = Redacted.isRedacted(secret) // true
Redacted<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_.interface Redacted<out A = string>A wrapper for sensitive values whose string, JSON, and inspection output is
redacted.
When to use
Use to carry sensitive values while reducing accidental exposure in string,
JSON, and inspection output.
Gotchas
The underlying value is still stored in memory and can be recovered with
Redacted.value until the wrapper is wiped or becomes unreachable. Use
Redacted to reduce accidental disclosure in logs and diagnostics, not as a
cryptographic protection mechanism.
Example (Creating redacted values)
import { Redacted } from "effect"
// Create a redacted value to protect sensitive information
const apiKey = Redacted.make("secret-key")
const userPassword = Redacted.make("user-password")
// TypeScript will infer the types as Redacted<string>
Namespace containing type-level members associated with Redacted values.
When to use
Use to access type-level helpers associated with Redacted.
Example (Using namespace utilities)
import { Redacted } from "effect"
// Use the Redacted namespace for type-level operations
const secret = Redacted.make("my-secret")
// The namespace contains utilities for working with Redacted values
const isRedacted = Redacted.isRedacted(secret) // true
Redacted<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_.const isRedacted: (
u: unknown
) => u is Redacted<unknown>
Returns true if a value is a Redacted wrapper.
When to use
Use to validate unknown input and narrow it to Redacted.
Details
When this function returns true, TypeScript narrows the value to
Redacted<unknown>.
Example (Checking for redacted values)
import { Redacted } from "effect"
const secret = Redacted.make("my-secret")
const plainString = "not-secret"
console.log(Redacted.isRedacted(secret)) // true
console.log(Redacted.isRedacted(plainString)) // false
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.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<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.const mapErrorEager: {
<E, E2>(f: (e: E) => E2): <A, R>(
self: Effect<A, E, R>
) => Effect<A, E2, R>
<A, E, R, E2>(
self: Effect<A, E, R>,
f: (e: E) => E2
): Effect<A, E2, R>
}
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.Redacted<unknown>.label: string | undefinedlabel, 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.const void: Effect.Effect<void, never, never>(alias) const void: {
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;
}
Returns an effect that succeeds with void.
void
return import EffectEffect.const flatMapEager: {
<A, B, E2, R2>(
f: (a: A) => Effect<B, E2, R2>
): <E, R>(
self: Effect<A, E, R>
) => Effect<B, E | E2, R | R2>
<A, E, R, B, E2, R2>(
self: Effect<A, E, R>,
f: (a: A) => Effect<B, E2, R2>
): Effect<B, E | E2, R | R2>
}
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.const mapBothEager: {
<E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2
readonly onSuccess: (a: A) => A2
}): <R>(
self: Effect<A, E, R>
) => Effect<A2, E2, R>
<A, E, R, E2, A2>(
self: Effect<A, E, R>,
options: {
readonly onFailure: (e: E) => E2
readonly onSuccess: (a: A) => A2
}
): Effect<A2, E2, R>
}
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_.const value: <T>(self: Redacted<T>) => TRetrieves the original value from a Redacted instance. Use this function
with caution, as it exposes the sensitive data.
When to use
Use when you need the underlying sensitive value at a trusted boundary.
Example (Retrieving a redacted value)
import { Redacted } from "effect"
import * as assert from "node:assert"
const API_KEY = Redacted.make("1234567890")
assert.equal(Redacted.value(API_KEY), "1234567890")
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: (
a: S["Type"]
) => Redacted_.Redacted<unknown>
onSuccess: () => 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: (
e: SchemaIssue.Issue
) => SchemaIssue.Composite
onFailure: (/** ignore the actual issue because of security reasons */) => {
const const oinput: Option_.Option<
Redacted_.Redacted<unknown>
>
oinput = import Option_Option_.const some: <A>(value: A) => Option<A>Wraps the given value into an Option to represent its presence.
When to use
Use to wrap a known present value as Option
- Returning a successful result from a partial function
Details
- Always returns
Some<A>
- Does not filter
null or undefined; use
fromNullishOr
for that
Example (Wrapping a value)
import { Option } from "effect"
// ┌─── Option<number>
// ▼
const value = Option.some(1)
console.log(value)
// Output: { _id: 'Option', _tag: 'Some', value: 1 }
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: Option_.Option<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: Option_.Option<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.const fail: <E>(
error: E
) => Effect<never, E>
Creates an Effect that represents a recoverable error.
When to use
Use to explicitly signal a recoverable error in an Effect.
Details
The error keeps propagating unless it is handled. You can handle tagged
errors with functions like
catchTag
or
catchTags
.
Example (Creating a failed effect)
import { Data, Effect } from "effect"
class OperationFailedError extends Data.TaggedError("OperationFailedError")<{}> {}
// ┌─── Effect<never, OperationFailedError, never>
// ▼
const failure = Effect.fail(
new OperationFailedError()
)
fail(new import SchemaIssueSchemaIssue.constructor InvalidType(ast: SchemaAST.AST, actual: Option_.Option<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_.const some: <A>(value: A) => Option<A>Wraps the given value into an Option to represent its presence.
When to use
Use to wrap a known present value as Option
- Returning a successful result from a partial function
Details
- Always returns
Some<A>
- Does not filter
null or undefined; use
fromNullishOr
for that
Example (Wrapping a value)
import { Option } from "effect"
// ┌─── Option<number>
// ▼
const value = Option.some(1)
console.log(value)
// Output: { _id: 'Option', _tag: 'Some', value: 1 }
some(input: unknowninput)))
},
{
Annotations.Declaration<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<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(?, ${function format(input: unknown, options?: {
readonly space?: number | string | undefined;
readonly ignoreToString?: boolean | undefined;
}): string
Converts any JavaScript value into a human-readable string.
When to use
Use when you need to format arbitrary JavaScript values for debugging,
logging, or error messages.
Details
- Output is not valid JSON; use
formatJson
when you need
parseable JSON.
- Handles
BigInt, Symbol, Set, Map, Date, RegExp, and class
instances that JSON.stringify cannot represent.
- Circular references are shown as
"[Circular]" instead of throwing.
- Primitives: stringified naturally (
null, undefined, 123, true).
Strings are JSON-quoted.
- Objects with a custom
toString (not Object.prototype.toString):
toString() is called unless ignoreToString is true.
- Errors with a
cause: formatted as "<message> (cause: <cause>)".
- Iterables (
Set, Map, etc.): formatted as
ClassName([...elements]).
- Class instances: wrapped as
ClassName({...}).
Redactable values are automatically redacted.
- Arrays/objects with 0–1 entries are inline; larger ones are
pretty-printed when
space is set.
space — indentation unit (number of spaces, or a string like
"\t"). Defaults to 0 (compact).
ignoreToString — skip calling toString(). Defaults to false.
Example (Formatting compact output)
import { Formatter } from "effect"
console.log(Formatter.format({ a: 1, b: [2, 3] }))
// {"a":1,"b":[2,3]}
Example (Pretty-printed output)
import { Formatter } from "effect"
console.log(Formatter.format({ a: 1, b: [2, 3] }, { space: 2 }))
// {
// "a": 1,
// "b": [
// 2,
// 3
// ]
// }
Example (Handling circular references)
import { Formatter } from "effect"
const obj: any = { name: "loop" }
obj.self = obj
console.log(Formatter.format(obj))
// {"name":"loop","self":[Circular]}
format(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<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_.interface Redacted<out A = string>A wrapper for sensitive values whose string, JSON, and inspection output is
redacted.
When to use
Use to carry sensitive values while reducing accidental exposure in string,
JSON, and inspection output.
Gotchas
The underlying value is still stored in memory and can be recovered with
Redacted.value until the wrapper is wiped or becomes unreachable. Use
Redacted to reduce accidental disclosure in logs and diagnostics, not as a
cryptographic protection mechanism.
Example (Creating redacted values)
import { Redacted } from "effect"
// Create a redacted value to protect sensitive information
const apiKey = Redacted.make("secret-key")
const userPassword = Redacted.make("user-password")
// TypeScript will infer the types as Redacted<string>
Namespace containing type-level members associated with Redacted values.
When to use
Use to access type-level helpers associated with Redacted.
Example (Using namespace utilities)
import { Redacted } from "effect"
// Use the Redacted namespace for type-level operations
const secret = Redacted.make("my-secret")
// The namespace contains utilities for working with Redacted values
const isRedacted = Redacted.isRedacted(secret) // true
Redacted<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_.const make: <T>(
value: T,
options?: {
readonly label?: string | undefined
}
) => Redacted<T>
Creates a Redacted wrapper for a sensitive value.
When to use
Use to wrap a sensitive value so normal string, JSON, and inspection output
is redacted.
Details
The wrapper redacts string, JSON, and inspection output to reduce accidental
disclosure. The original value remains retrievable with Redacted.value
until the wrapper is wiped or becomes unreachable.
Example (Creating a redacted value)
import { Redacted } from "effect"
const API_KEY = Redacted.make("1234567890")
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_.const isSome: <A>(
self: Option<A>
) => self is Some<A>
Checks whether an Option contains a value (Some).
When to use
Use when you need to branch on a present Option before accessing .value.
Details
- Acts as a type guard, narrowing to
Some<A>
Example (Checking for Some)
import { Option } from "effect"
console.log(Option.isSome(Option.some(1)))
// Output: true
console.log(Option.isSome(Option.none()))
// Output: false
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.Some<Redacted<S["Encoded"]>>.value: Redacted_.Redacted<S["Encoded"]>(property) Some<Redacted<S["Encoded"]>>.value: {
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; <…;
}
value.Redacted<S["Encoded"]>.label: string | undefinedlabel === "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.Some<Redacted<S["Encoded"]>>.value: Redacted_.Redacted<S["Encoded"]>(property) Some<Redacted<S["Encoded"]>>.value: {
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; <…;
}
value.Redacted<S["Encoded"]>.label: stringlabel}"` : "")
) :
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_.const value: <T>(self: Redacted<T>) => TRetrieves the original value from a Redacted instance. Use this function
with caution, as it exposes the sensitive data.
When to use
Use when you need the underlying sensitive value at a trusted boundary.
Example (Retrieving a redacted value)
import { Redacted } from "effect"
import * as assert from "node:assert"
const API_KEY = Redacted.make("1234567890")
assert.equal(Redacted.value(API_KEY), "1234567890")
value)
}
),
Annotations.Declaration<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_.const make: <T>(
value: T,
options?: {
readonly label?: string | undefined
}
) => Redacted<T>
Creates a Redacted wrapper for a sensitive value.
When to use
Use to wrap a sensitive value so normal string, JSON, and inspection output
is redacted.
Details
The wrapper redacts string, JSON, and inspection output to reduce accidental
disclosure. The original value remains retrievable with Redacted.value
until the wrapper is wiped or becomes unreachable.
Example (Creating a redacted value)
import { Redacted } from "effect"
const API_KEY = Redacted.make("1234567890")
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_.const make: <T>(
value: T,
options?: {
readonly label?: string | undefined
}
) => Redacted<T>
Creates a Redacted wrapper for a sensitive value.
When to use
Use to wrap a sensitive value so normal string, JSON, and inspection output
is redacted.
Details
The wrapper redacts string, JSON, and inspection output to reduce accidental
disclosure. The original value remains retrievable with Redacted.value
until the wrapper is wiped or becomes unreachable.
Example (Creating a redacted value)
import { Redacted } from "effect"
const API_KEY = Redacted.make("1234567890")
make(a: anya, { label?: string | undefinedlabel: options: | {
readonly label?: string | undefined
readonly disallowJsonEncode?:
| boolean
| undefined
}
| undefined
options?.label?: string | undefinedlabel }))
}),
Annotations.Declaration<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<S["Type"]>, readonly [S]>.toEquivalence?: Annotations.ToEquivalence.Declaration<Redacted_.Redacted<S["Type"]>, readonly [S]> | undefinedtoEquivalence: ([value: Equivalence.Equivalence<S["Type"]>value]) => import Redacted_Redacted_.const makeEquivalence: <A>(
isEquivalent: Equivalence.Equivalence<A>
) => Equivalence.Equivalence<Redacted<A>>
Generates an equivalence relation for Redacted<A> values based on an
equivalence relation for the underlying values A. This function is useful
for comparing Redacted instances without exposing their contents.
When to use
Use when you need to compare wrapped secrets through an approved equality
rule without exposing the underlying values at each comparison site.
Example (Comparing redacted values)
import { Equivalence, Redacted } from "effect"
import * as assert from "node:assert"
const API_KEY1 = Redacted.make("1234567890")
const API_KEY2 = Redacted.make("1-34567890")
const API_KEY3 = Redacted.make("1234567890")
const equivalence = Redacted.makeEquivalence(Equivalence.strictEqual<string>())
assert.equal(equivalence(API_KEY1, API_KEY2), false)
assert.equal(equivalence(API_KEY1, API_KEY3), true)
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<S["Type"]>, Redacted<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"], Declaration, declareConstructor<Redacted<S["Type"]>, Redacted<...>, readonly [...], Redacted<...>>, ... 8 more ..., "required">["ast"]: SchemaAST.Declaration(property) Bottom<Redacted<S["Type"]>, Redacted<S["Encoded"]>, S["DecodingServices"], S["EncodingServices"], Declaration, declareConstructor<Redacted<S["Type"]>, Redacted<...>, readonly [...], 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 })
}