(
declaration: Declaration,
recur: (representation: Representation) => Schema.Top
): Schema.Top | undefinedDefault Reviver for toSchema that handles built-in Effect types, including Option, Result, Redacted, Cause, Exit, ReadonlyMap, HashMap, ReadonlySet, Date, Duration, URL, and RegExp.
When to use
Use when you need the default options.reviver for toSchema to
reconstruct runtime schemas for built-in Effect declarations.
Details
The reviver returns undefined for unrecognized declarations, causing
fallback to encodedSchema.
export const const toSchemaDefaultReviver: Reviver<Schema.Top>Default
Reviver
for
toSchema
that handles built-in Effect
types, including Option, Result, Redacted, Cause, Exit, ReadonlyMap, HashMap,
ReadonlySet, Date, Duration, URL, and RegExp.
When to use
Use when you need the default options.reviver for
toSchema
to
reconstruct runtime schemas for built-in Effect declarations.
Details
The reviver returns undefined for unrecognized declarations, causing
fallback to encodedSchema.
toSchemaDefaultReviver: type Reviver<T> = (
declaration: Declaration,
recur: (representation: Representation) => T
) => T | undefined
A callback that handles
Declaration
nodes during reconstruction
(
toSchema
) or code generation (
toCodeDocument
).
Details
Return a value to handle the declaration. Return undefined to fall back to
default behavior, which uses encodedSchema for toSchema or the
generation annotation for toCodeDocument. recur processes child
representations recursively.
Reviver<import SchemaSchema.Top> = (s: Declaration(parameter) s: {
_tag: "Declaration";
annotations: Schema.Annotations.Annotations | undefined;
typeParameters: ReadonlyArray<Representation>;
checks: ReadonlyArray<Check<DeclarationMeta>>;
encodedSchema: Representation;
}
s, recur: (
representation: Representation
) => Schema.Top
recur) => {
const const typeConstructor: unknowntypeConstructor = s: Declaration(parameter) s: {
_tag: "Declaration";
annotations: Schema.Annotations.Annotations | undefined;
typeParameters: ReadonlyArray<Representation>;
checks: ReadonlyArray<Check<DeclarationMeta>>;
encodedSchema: Representation;
}
s.Declaration.annotations?: Schema.Annotations.Annotations | undefinedannotations?.unknowntypeConstructor
if (import PredicatePredicate.function isObject(
input: unknown
): input is {
[x: PropertyKey]: unknown
}
Checks whether a value is a non-null object value that is not an array.
When to use
Use to narrow unknown input to a non-null, non-array object with a
Predicate guard.
Details
This is a structural runtime check using typeof input === "object", so it
also accepts object instances such as Date, Map, class instances, and
typed arrays. It excludes null and arrays.
Example (Guarding objects)
import { Predicate } from "effect"
console.log(Predicate.isObject({ a: 1 }))
console.log(Predicate.isObject([1, 2]))
isObject(const typeConstructor: unknowntypeConstructor) && typeof const typeConstructor: {
[x: string]: unknown
[x: number]: unknown
[x: symbol]: unknown
}
typeConstructor.__type[string | number | symbol]: unknown_tag === "string") {
const const typeParameters: Array<Schema.Top>typeParameters = s: Declaration(parameter) s: {
_tag: "Declaration";
annotations: Schema.Annotations.Annotations | undefined;
typeParameters: ReadonlyArray<Representation>;
checks: ReadonlyArray<Check<DeclarationMeta>>;
encodedSchema: Representation;
}
s.Declaration.typeParameters: ReadonlyArray<Representation>typeParameters.ReadonlyArray<Representation>.map<Schema.Top>(callbackfn: (value: Representation, index: number, array: readonly Representation[]) => Schema.Top, thisArg?: any): Schema.Top[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(recur: (
representation: Representation
) => Schema.Top
recur)
switch (const typeConstructor: {
[x: string]: unknown
[x: number]: unknown
[x: symbol]: unknown
}
typeConstructor.__type[string | number | symbol]: string_tag) {
// built-in types
case "Date":
return import SchemaSchema.const Date: Dateconst Date: {
Rebuild: Date;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<Date, readonly []>) => Schema.Date;
annotateKey: (annotations: Schema.Annotations.Key<Date>) => Schema.Date;
check: (checks_0: SchemaAST.Check<Date>, ...checks: Array<SchemaAST.Check<Date>>) => Schema.Date;
rebuild: (ast: SchemaAST.Declaration) => Schema.Date;
make: (input: globalThis.Date, options?: MakeOptions) => globalThis.Date;
makeOption: (input: globalThis.Date, options?: MakeOptions) => Option_.Option<globalThis.Date>;
makeEffect: (input: globalThis.Date, options?: MakeOptions) => Effect.Effect<globalThis.Date, 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; <…;
}
Type-level representation of
Date
.
Schema for JavaScript Date objects.
When to use
Use to validate in-memory values that must already be JavaScript date
objects.
Details
This schema accepts any Date instance, including invalid dates. The default
JSON serializer encodes valid dates as ISO 8601 strings; invalid dates encode
as "Invalid Date".
Example (Defining a Date schema)
import { Schema } from "effect"
Schema.decodeUnknownSync(Schema.Date)(new Date("2024-01-01"))
// => Date { 2024-01-01T00:00:00.000Z }
Date
case "Error":
return import SchemaSchema.function Error(
options?: ErrorOptions
): Error
Schema for JavaScript Error objects.
Details
Default JSON serializer:
Encodes an Error as an object with message, optional name, and optional
cause properties, and decodes that object back into an Error. Stack
traces are omitted by default for security. Pass { includeStack: true } to
include stack traces, or { excludeCause: true } to omit causes.
Error(const typeConstructor: {
[x: string]: unknown
[x: number]: unknown
[x: symbol]: unknown
}
typeConstructor.__type[string | number | symbol]: unknownoptions as import SchemaSchema.ErrorOptions | undefined)
case "File":
return import SchemaSchema.const File: Fileconst File: {
Rebuild: File;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<File, readonly []>) => Schema.File;
annotateKey: (annotations: Schema.Annotations.Key<File>) => Schema.File;
check: (checks_0: SchemaAST.Check<File>, ...checks: Array<SchemaAST.Check<File>>) => Schema.File;
rebuild: (ast: SchemaAST.Declaration) => Schema.File;
make: (input: globalThis.File, options?: MakeOptions) => globalThis.File;
makeOption: (input: globalThis.File, options?: MakeOptions) => Option_.Option<globalThis.File>;
makeEffect: (input: globalThis.File, options?: MakeOptions) => Effect.Effect<globalThis.File, 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; <…;
}
Type-level representation of
File
.
Schema for JavaScript File objects.
Details
The default JSON serializer encodes a File as { data, type, name, lastModified }
where data is base64-encoded.
File
case "FormData":
return import SchemaSchema.const FormData: FormDataconst FormData: {
Rebuild: FormData;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<FormData, readonly []>) => Schema.FormData;
annotateKey: (annotations: Schema.Annotations.Key<FormData>) => Schema.FormData;
check: (checks_0: SchemaAST.Check<FormData>, ...checks: Array<SchemaAST.Check<FormData>>) => Schema.FormData;
rebuild: (ast: SchemaAST.Declaration) => Schema.FormData;
make: (input: globalThis.FormData, options?: MakeOptions) => globalThis.FormData;
makeOption: (input: globalThis.FormData, options?: MakeOptions) => Option_.Option<globalThis.FormData>;
makeEffect: (input: globalThis.FormData, options?: MakeOptions) => Effect.Effect<globalThis.FormData, 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; <…;
}
Type-level representation of
FormData
.
Schema for JavaScript FormData objects.
Details
The default JSON serializer encodes a FormData as an array of [key, entry]
pairs where each entry is tagged as "String" or "File".
FormData
case "ReadonlyMap":
return import SchemaSchema.function ReadonlyMap<
Key extends Constraint,
Value extends Constraint
>(
key: Key,
value: Value
): $ReadonlyMap<Key, Value>
Schema for readonly maps whose keys and values conform to the provided
schemas.
ReadonlyMap(const typeParameters: Array<Schema.Top>typeParameters[0], const typeParameters: Array<Schema.Top>typeParameters[1])
case "ReadonlySet":
return import SchemaSchema.function ReadonlySet<
Value extends Constraint
>(value: Value): $ReadonlySet<Value>
Schema for readonly sets whose values conform to the provided element schema.
ReadonlySet(const typeParameters: Array<Schema.Top>typeParameters[0])
case "RegExp":
return import SchemaSchema.const RegExp: RegExpconst RegExp: {
Rebuild: RegExp;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<RegExp, readonly []>) => Schema.RegExp;
annotateKey: (annotations: Schema.Annotations.Key<RegExp>) => Schema.RegExp;
check: (checks_0: SchemaAST.Check<RegExp>, ...checks: Array<SchemaAST.Check<RegExp>>) => Schema.RegExp;
rebuild: (ast: SchemaAST.Declaration) => Schema.RegExp;
make: (input: globalThis.RegExp, options?: MakeOptions) => globalThis.RegExp;
makeOption: (input: globalThis.RegExp, options?: MakeOptions) => Option_.Option<globalThis.RegExp>;
makeEffect: (input: globalThis.RegExp, options?: MakeOptions) => Effect.Effect<globalThis.RegExp, 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; <…;
}
Type-level representation of
RegExp
.
Schema for JavaScript RegExp objects.
Details
The default JSON serializer encodes a RegExp as { source, flags }.
RegExp
case "Uint8Array":
return import SchemaSchema.const Uint8Array: Uint8Arrayconst Uint8Array: {
Rebuild: Uint8Array;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<Uint8Array<ArrayBufferLike>, readonly []>) => Schema.Uint8Array;
annotateKey: (annotations: Schema.Annotations.Key<Uint8Array<ArrayBufferLike>>) => Schema.Uint8Array;
check: (checks_0: SchemaAST.Check<Uint8Array<ArrayBufferLike>>, ...checks: Array<SchemaAST.Check<Uint8Array<ArrayBufferLike>>>) => Schema.Uint8Array;
rebuild: (ast: SchemaAST.Declaration) => Schema.Uint8Array;
make: (input: globalThis.Uint8Array<ArrayBufferLike>, options?: MakeOptions) => globalThis.Uint8Array<ArrayBufferLike>;
makeOption: (input: globalThis.Uint8Array<ArrayBufferLike>, options?: MakeOptions) => Option_.Option<globalThis.Uint8Array<ArrayBufferLike>>;
makeEffect: (input: globalThis.Uint8Array<ArrayBufferLike>, options?: MakeOptions) => Effect.Effect<globalThis.Uint8Array<ArrayBufferLike>, 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; <…;
}
Type-level representation of
Uint8Array
.
Schema for JavaScript Uint8Array objects.
Details
Default JSON serializer:
The default JSON serializer encodes Uint8Array as a Base64 encoded string.
Uint8Array
case "URL":
return import SchemaSchema.const URL: URLconst URL: {
Rebuild: URL;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<URL, readonly []>) => Schema.URL;
annotateKey: (annotations: Schema.Annotations.Key<URL>) => Schema.URL;
check: (checks_0: SchemaAST.Check<URL>, ...checks: Array<SchemaAST.Check<URL>>) => Schema.URL;
rebuild: (ast: SchemaAST.Declaration) => Schema.URL;
make: (input: globalThis.URL, options?: MakeOptions) => globalThis.URL;
makeOption: (input: globalThis.URL, options?: MakeOptions) => Option_.Option<globalThis.URL>;
makeEffect: (input: globalThis.URL, options?: MakeOptions) => Effect.Effect<globalThis.URL, 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; <…;
}
Type-level representation of
URL
.
Schema for JavaScript URL objects.
Details
Default JSON serializer:
- encodes
URL as a string
URL
case "URLSearchParams":
return import SchemaSchema.const URLSearchParams: URLSearchParamsconst URLSearchParams: {
Rebuild: URLSearchParams;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<URLSearchParams, readonly []>) => Schema.URLSearchParams;
annotateKey: (annotations: Schema.Annotations.Key<URLSearchParams>) => Schema.URLSearchParams;
check: (checks_0: SchemaAST.Check<URLSearchParams>, ...checks: Array<SchemaAST.Check<URLSearchParams>>) => Schema.URLSearchParams;
rebuild: (ast: SchemaAST.Declaration) => Schema.URLSearchParams;
make: (input: globalThis.URLSearchParams, options?: MakeOptions) => globalThis.URLSearchParams;
makeOption: (input: globalThis.URLSearchParams, options?: MakeOptions) => Option_.Option<globalThis.URLSearchParams>;
makeEffect: (input: globalThis.URLSearchParams, options?: MakeOptions) => Effect.Effect<globalThis.URLSearchParams, 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; <…;
}
Type-level representation of
URLSearchParams
.
Schema for JavaScript URLSearchParams objects.
Details
The default JSON serializer encodes a URLSearchParams as a query string.
URLSearchParams
// effect types
case "effect/Option":
return import SchemaSchema.function Option<A extends Constraint>(
value: A
): Option<A>
Schema for Option<A> values.
Option(const typeParameters: Array<Schema.Top>typeParameters[0])
case "effect/Result":
return import SchemaSchema.function Result<
A extends Constraint,
E extends Constraint
>(success: A, failure: E): Result<A, E>
Schema for Result<A, E> values.
Result(const typeParameters: Array<Schema.Top>typeParameters[0], const typeParameters: Array<Schema.Top>typeParameters[1])
case "effect/Redacted":
return import SchemaSchema.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(const typeParameters: Array<Schema.Top>typeParameters[0], const typeConstructor: {
[x: string]: unknown
[x: number]: unknown
[x: symbol]: unknown
}
typeConstructor.__type[string | number | symbol]: unknownoptions as any)
case "effect/DateTime.TimeZone":
return import SchemaSchema.const TimeZone: TimeZoneconst TimeZone: {
Rebuild: TimeZone;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<TimeZone, readonly []>) => Schema.TimeZone;
annotateKey: (annotations: Schema.Annotations.Key<TimeZone>) => Schema.TimeZone;
check: (checks_0: SchemaAST.Check<TimeZone>, ...checks: Array<SchemaAST.Check<TimeZone>>) => Schema.TimeZone;
rebuild: (ast: SchemaAST.Declaration) => Schema.TimeZone;
make: (input: DateTime.TimeZone, options?: MakeOptions) => DateTime.TimeZone;
makeOption: (input: DateTime.TimeZone, options?: MakeOptions) => Option_.Option<DateTime.TimeZone>;
makeEffect: (input: DateTime.TimeZone, options?: MakeOptions) => Effect.Effect<DateTime.TimeZone, 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; <…;
}
Type-level representation of
TimeZone
.
Schema for DateTime.TimeZone values.
Details
Default JSON serializer:
- encodes
DateTime.TimeZone as a string (IANA identifier or offset like
+03:00)
TimeZone
case "effect/DateTime.TimeZone.Named":
return import SchemaSchema.const TimeZoneNamed: TimeZoneNamedconst TimeZoneNamed: {
Rebuild: TimeZoneNamed;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<TimeZone.Named, readonly []>) => Schema.TimeZoneNamed;
annotateKey: (annotations: Schema.Annotations.Key<TimeZone.Named>) => Schema.TimeZoneNamed;
check: (checks_0: SchemaAST.Check<TimeZone.Named>, ...checks: Array<SchemaAST.Check<TimeZone.Named>>) => Schema.TimeZoneNamed;
rebuild: (ast: SchemaAST.Declaration) => Schema.TimeZoneNamed;
make: (input: DateTime.TimeZone.Named, options?: MakeOptions) => DateTime.TimeZone.Named;
makeOption: (input: DateTime.TimeZone.Named, options?: MakeOptions) => Option_.Option<DateTime.TimeZone.Named>;
makeEffect: (input: DateTime.TimeZone.Named, options?: MakeOptions) => Effect.Effect<DateTime.TimeZone.Named, 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; <…;
}
Type-level representation of
TimeZoneNamed
.
Schema for DateTime.TimeZone.Named values.
Details
Default JSON serializer:
- encodes
DateTime.TimeZone.Named as a string (IANA time zone identifier)
TimeZoneNamed
case "effect/DateTime.TimeZone.Offset":
return import SchemaSchema.const TimeZoneOffset: TimeZoneOffsetconst TimeZoneOffset: {
Rebuild: TimeZoneOffset;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<TimeZone.Offset, readonly []>) => Schema.TimeZoneOffset;
annotateKey: (annotations: Schema.Annotations.Key<TimeZone.Offset>) => Schema.TimeZoneOffset;
check: (checks_0: SchemaAST.Check<TimeZone.Offset>, ...checks: Array<SchemaAST.Check<TimeZone.Offset>>) => Schema.TimeZoneOffset;
rebuild: (ast: SchemaAST.Declaration) => Schema.TimeZoneOffset;
make: (input: DateTime.TimeZone.Offset, options?: MakeOptions) => DateTime.TimeZone.Offset;
makeOption: (input: DateTime.TimeZone.Offset, options?: MakeOptions) => Option_.Option<DateTime.TimeZone.Offset>;
makeEffect: (input: DateTime.TimeZone.Offset, options?: MakeOptions) => Effect.Effect<DateTime.TimeZone.Offset, 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; <…;
}
Type-level representation of
TimeZoneOffset
.
Schema for DateTime.TimeZone.Offset values.
Details
Default JSON serializer:
- encodes
DateTime.TimeZone.Offset as a number (offset in milliseconds)
TimeZoneOffset
case "effect/DateTime.Utc":
return import SchemaSchema.const DateTimeUtc: DateTimeUtcconst DateTimeUtc: {
Rebuild: DateTimeUtc;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<Utc, readonly []>) => Schema.DateTimeUtc;
annotateKey: (annotations: Schema.Annotations.Key<Utc>) => Schema.DateTimeUtc;
check: (checks_0: SchemaAST.Check<Utc>, ...checks: Array<SchemaAST.Check<Utc>>) => Schema.DateTimeUtc;
rebuild: (ast: SchemaAST.Declaration) => Schema.DateTimeUtc;
make: (input: DateTime.Utc, options?: MakeOptions) => DateTime.Utc;
makeOption: (input: DateTime.Utc, options?: MakeOptions) => Option_.Option<DateTime.Utc>;
makeEffect: (input: DateTime.Utc, options?: MakeOptions) => Effect.Effect<DateTime.Utc, 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; <…;
}
Type-level representation of
DateTimeUtc
.
Schema for DateTime.Utc values.
When to use
Use to validate existing DateTime.Utc schema values and use the default JSON
codec that represents them as UTC ISO strings.
Details
The default JSON codec decodes UTC ISO strings into DateTime.Utc values and
encodes DateTime.Utc values as UTC ISO strings.
DateTimeUtc
case "effect/DateTime.Zoned":
return import SchemaSchema.const DateTimeZoned: DateTimeZonedconst DateTimeZoned: {
Rebuild: DateTimeZoned;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<Zoned, readonly []>) => Schema.DateTimeZoned;
annotateKey: (annotations: Schema.Annotations.Key<Zoned>) => Schema.DateTimeZoned;
check: (checks_0: SchemaAST.Check<Zoned>, ...checks: Array<SchemaAST.Check<Zoned>>) => Schema.DateTimeZoned;
rebuild: (ast: SchemaAST.Declaration) => Schema.DateTimeZoned;
make: (input: DateTime.Zoned, options?: MakeOptions) => DateTime.Zoned;
makeOption: (input: DateTime.Zoned, options?: MakeOptions) => Option_.Option<DateTime.Zoned>;
makeEffect: (input: DateTime.Zoned, options?: MakeOptions) => Effect.Effect<DateTime.Zoned, 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; <…;
}
Type-level representation of
DateTimeZoned
.
Schema for DateTime.Zoned values.
Details
Default JSON serializer:
- encodes offset zones as an ISO date-time with a numeric offset, such as
YYYY-MM-DDTHH:mm:ss.sss+HH:MM
- encodes named zones by appending the IANA identifier in brackets, such as
YYYY-MM-DDTHH:mm:ss.sss+HH:MM[Time/Zone]
DateTimeZoned
case "effect/BigDecimal":
return import SchemaSchema.const BigDecimal: BigDecimalconst BigDecimal: {
Rebuild: BigDecimal;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<BigDecimal, readonly []>) => Schema.BigDecimal;
annotateKey: (annotations: Schema.Annotations.Key<BigDecimal>) => Schema.BigDecimal;
check: (checks_0: SchemaAST.Check<BigDecimal>, ...checks: Array<SchemaAST.Check<BigDecimal>>) => Schema.BigDecimal;
rebuild: (ast: SchemaAST.Declaration) => Schema.BigDecimal;
make: (input: BigDecimal_.BigDecimal, options?: MakeOptions) => BigDecimal_.BigDecimal;
makeOption: (input: BigDecimal_.BigDecimal, options?: MakeOptions) => Option_.Option<BigDecimal_.BigDecimal>;
makeEffect: (input: BigDecimal_.BigDecimal, options?: MakeOptions) => Effect.Effect<BigDecimal_.BigDecimal, 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; <…;
}
Type-level representation of
BigDecimal
.
Schema for BigDecimal values.
When to use
Use when you already have Effect decimal instances and need schema
validation, formatting, equivalence, and JSON string serialization.
Details
Default JSON serializer:
- encodes
BigDecimal as a string
BigDecimal
case "effect/Chunk":
return import SchemaSchema.function Chunk<Value extends Constraint>(
value: Value
): Chunk<Value>
Schema for chunks whose values conform to the provided element schema.
Chunk(const typeParameters: Array<Schema.Top>typeParameters[0])
case "effect/Cause":
return import SchemaSchema.function Cause<
E extends Constraint,
D extends Constraint
>(error: E, defect: D): Cause<E, D>
Creates a schema for Cause values using separate schemas for typed failures
and unexpected defects.
When to use
Use to validate, transform, or serialize Effect failure causes when typed
failures and unexpected defects need separate schemas.
Details
The error schema is applied to Fail reasons and the defect schema is
applied to Die reasons. Interrupt reasons do not use either schema and
carry only an optional fiber id.
Cause(const typeParameters: Array<Schema.Top>typeParameters[0], const typeParameters: Array<Schema.Top>typeParameters[1])
case "effect/Cause/Failure":
return import SchemaSchema.function CauseReason<
E extends Constraint,
D extends Constraint
>(error: E, defect: D): CauseReason<E, D>
Creates a schema for Cause.Reason values using separate schemas for typed
failures and unexpected defects.
When to use
Use when serializing or decoding individual cause reasons separately from a
full failure cause, with distinct schemas for typed errors and defects.
Details
Fail reasons use the error schema, Die reasons use the defect schema,
and Interrupt reasons carry only an optional fiber id.
CauseReason(const typeParameters: Array<Schema.Top>typeParameters[0], const typeParameters: Array<Schema.Top>typeParameters[1])
case "effect/Duration":
return import SchemaSchema.const Duration: Durationconst Duration: {
Rebuild: Duration;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<Duration, readonly []>) => Schema.Duration;
annotateKey: (annotations: Schema.Annotations.Key<Duration>) => Schema.Duration;
check: (checks_0: SchemaAST.Check<Duration>, ...checks: Array<SchemaAST.Check<Duration>>) => Schema.Duration;
rebuild: (ast: SchemaAST.Declaration) => Schema.Duration;
make: (input: Duration_.Duration, options?: MakeOptions) => Duration_.Duration;
makeOption: (input: Duration_.Duration, options?: MakeOptions) => Option_.Option<Duration_.Duration>;
makeEffect: (input: Duration_.Duration, options?: MakeOptions) => Effect.Effect<Duration_.Duration, 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; <…;
}
Type-level representation of
Duration
.
Schema for Duration values.
Details
The default JSON serializer encodes Duration as a tagged object with the
duration type and value.
Example (Defining a Duration schema)
import { Duration, Schema } from "effect"
Schema.decodeUnknownSync(Schema.Duration)(Duration.seconds(5))
// => Duration(5s)
Duration
case "effect/Exit":
return import SchemaSchema.function Exit<
A extends Constraint,
E extends Constraint,
D extends Constraint
>(value: A, error: E, defect: D): Exit<A, E, D>
Creates a schema for Exit values using schemas for the success value, typed
failure, and unexpected defect channels.
When to use
Use when serializing or validating an effect outcome where success, typed
failure, and defects each need their own schema.
Exit(const typeParameters: Array<Schema.Top>typeParameters[0], const typeParameters: Array<Schema.Top>typeParameters[1], const typeParameters: Array<Schema.Top>typeParameters[2])
case "effect/Json":
return import SchemaSchema.const Json: Codec<Json>const Json: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<Schema.Json, any>) => Schema.Codec<Schema.Json, Schema.Json, never, never>;
annotateKey: (annotations: Schema.Annotations.Key<Schema.Json>) => Schema.Codec<Schema.Json, Schema.Json, never, never>;
check: (checks_0: SchemaAST.Check<Schema.Json>, ...checks: Array<SchemaAST.Check<Schema.Json>>) => Schema.Codec<Schema.Json, Schema.Json, never, never>;
rebuild: (ast: SchemaAST.AST) => Schema.Codec<Schema.Json, Schema.Json, never, never>;
make: (input: unknown, options?: MakeOptions) => Json;
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<Json>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<Json, 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; <…;
}
Recursive TypeScript type for any valid immutable JSON value: null,
number, boolean, string, a readonly array of Json values, or a
readonly record of string → Json. For the corresponding schema, see the
Json
const.
Schema that accepts and validates any immutable JSON-compatible value.
Example (Validating a JSON value)
import { Schema } from "effect"
const result = Schema.decodeUnknownOption(Schema.Json)({ key: [1, true, null] })
console.log(result._tag) // "Some"
Json
case "effect/MutableJson":
return import SchemaSchema.const MutableJson: Codec<MutableJson>const MutableJson: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<Schema.MutableJson, any>) => Schema.Codec<Schema.MutableJson, Schema.MutableJson, never, never>;
annotateKey: (annotations: Schema.Annotations.Key<Schema.MutableJson>) => Schema.Codec<Schema.MutableJson, Schema.MutableJson, never, never>;
check: (checks_0: SchemaAST.Check<Schema.MutableJson>, ...checks: Array<SchemaAST.Check<Schema.MutableJson>>) => Schema.Codec<Schema.MutableJson, Schema.MutableJson, never, never>;
rebuild: (ast: SchemaAST.AST) => Schema.Codec<Schema.MutableJson, Schema.MutableJson, never, never>;
make: (input: unknown, options?: MakeOptions) => MutableJson;
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<MutableJson>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<MutableJson, 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; <…;
}
Recursive TypeScript type for mutable JSON values: null, number,
boolean, string, mutable arrays, or mutable string-keyed records.
Schema that accepts any mutable JSON-compatible value. See
Json
for
the immutable variant.
MutableJson
case "effect/HashMap":
return import SchemaSchema.function HashMap<
Key extends Constraint,
Value extends Constraint
>(key: Key, value: Value): HashMap<Key, Value>
Schema for hash maps whose keys and values conform to the provided schemas.
HashMap(const typeParameters: Array<Schema.Top>typeParameters[0], const typeParameters: Array<Schema.Top>typeParameters[1])
case "effect/HashSet":
return import SchemaSchema.function HashSet<
Value extends Constraint
>(value: Value): HashSet<Value>
Schema for hash sets whose values conform to the provided element schema.
HashSet(const typeParameters: Array<Schema.Top>typeParameters[0])
}
}
}