SchemaRepresentation
Open, compiler-extensible representation of Effect schemas.
Annotations
CheckRepresentationAnnotation
interfaceOpen persistence identity and schema dependencies carried by opaque checks.
Signature
interface CheckRepresentationAnnotation<S> extends RepresentationAnnotation { readonly schemas?: readonly Array<S>;}RepresentationAnnotation
interfaceOpen persistence identity carried by declarations and opaque checks.
Signature
interface RepresentationAnnotation { readonly id: string; readonly payload: Json;}Configuration
ToRepresentationOptions
interfaceOptions for generating schema representations.
Signature
interface ToRepresentationOptions { readonly referencePolicy?: ReferencePolicy;}Constructors
Imports a JSON Schema Draft 2020-12 document as a runtime schema.
When to use
Use when you need to validate or transform values described by an external JSON Schema document.
Details
Translates a Draft 2020-12 subset using Effect schemas and built-in checks. Validation follows those checks and the
decoder's parse options, so import and re-export do not guarantee identical accepted values or a lossless round trip.
Import errors explain the unsupported constraint or reference and include its source path.
The input is assumed to be a valid Draft 2020-12 document; this function does not validate it against the meta-schema.
Instance validation semantics assume JSON-compatible JavaScript values produced by JSON.parse.
Gotchas
{ not: {} }imports asNever. Other uses ofnotare unsupported.- When
additionalPropertiesistrue,{}, or omitted, additional values useSchema.Jsonand are retained. Closed objects normally strip excess properties by default; passonExcessProperty: "error"to reject them. Closed empty objects instead useSchema.Record(Schema.String, Schema.Never)and reject string-keyed entries regardless of that option. Object keyword scopes still constrain declared properties in intersections. Combinations requiring index signatures that exclude explicit properties or patterned keys are rejected with an explanation of the limitation. - Property count and name checks run on the decoded object, after excess properties have been stripped.
- String
minLengthandmaxLengthchecks count Unicode code points, except thatminLength: 1uses the equivalent UTF-16 non-empty check.integerusesSchema.isInt, which requires safe integers. - Applied patterns use
Schema.isPatternwith theuflag. Patterns that cannot be compiled in Unicode mode are rejected as unsupported translations with their source path. $dynamicRef,contains,dependentRequired,dependentSchemas, activeif/then/else,unevaluatedItems, andunevaluatedPropertiesare rejected with an error identifying the unsupported keyword. Inactive conditional keywords andminContains/maxContainswithoutcontainshave no validation effect and are ignored.- Objects and arrays used as
constvalues orenummembers are rejected. Only strings, numbers, booleans, and null are supported. - Intersections of overlapping unions are limited to disjoint root-type partitions and finite primitive
anyOfliteral sets. Other union intersections, including cases that would duplicate a nested choice, are rejected. - Unknown extension keywords are ignored and their semantics are not enforced.
- Only direct local references to top-level definitions in the form
#/$defs/<escaped-token>are supported. Root references, external references, and pointers below a definition are rejected with the supported reference format. Missing definitions are reported by name. References reached inside nested schema resources introduced by$idare rejected instead of resolved against the top-level definitions. - Built-in declarations and checks are reconstructed with importer-owned revivers.
- Pattern constraints reached during translation cause an error by default. Use
patterns: "apply"only for trusted documents, orpatterns: "ignore"to skip them. Ignoring patterns can both admit invalid values and reject valid values whenoneOfbranches start overlapping. onEnterresults replace the corresponding input nodes before translation.- Callback results are used directly, and exceptions raised by a callback pass through unchanged.
See
- fromJsonSchemaMultiDocument for multiple roots sharing definitions
- toRepresentation for converting the result to a representation document
Signature
declare function fromJsonSchemaDocument(document: Document<"draft-2020-12">, options?: FromJsonSchemaOptions): TopImports multiple JSON Schema Draft 2020-12 roots as runtime schemas with shared definitions.
When to use
Use when multiple imported roots share reachable definitions, aliases, or recursion.
Details
Uses the same best-effort translation, built-in checks, and excess-property behavior as fromJsonSchemaDocument. The input is assumed to be a valid Draft 2020-12 document; this function does not validate it against the meta-schema.
Gotchas
- Only definitions reachable from a root are translated.
- Unsupported standard validation and applicator keywords are rejected with an error identifying the keyword. Unknown extension keywords are ignored and their semantics are not enforced.
- Objects and arrays used as
constvalues orenummembers are rejected. Only strings, numbers, booleans, and null are supported. - Intersections of overlapping unions are limited to disjoint root-type partitions and finite primitive
anyOfliteral sets. Other union intersections, including cases that would duplicate a nested choice, are rejected. - Only direct local references to top-level definitions in the form
#/$defs/<escaped-token>are supported. Root references, external references, and pointers below a definition are rejected with the supported reference format. Missing definitions are reported by name. References reached inside nested schema resources introduced by$idare rejected instead of resolved against the top-level definitions. - Pattern constraints reached during translation cause an error by default. Use
patterns: "apply"only for trusted documents, orpatterns: "ignore"to skip them. Ignoring patterns can both admit invalid values and reject valid values whenoneOfbranches start overlapping. - Callback results are used directly, and exceptions raised by a callback pass through unchanged.
See
- fromJsonSchemaDocument for a single root
- toRepresentations for converting the returned schema ASTs to a representation document
Signature
declare function fromJsonSchemaMultiDocument(document: MultiDocument<"draft-2020-12">, options?: FromJsonSchemaOptions): readonly [Top, Top]Creates generated runtime and TypeScript source strings for a schema.
Signature
declare const makeCode: (runtime: string, Type: string) => CodeCreates a declaration reviver while inferring its payload type from payloadSchema.
Signature
declare const makeReviverDeclaration: <P>(id: string, payloadSchema: Schema.Decoder<P>, revive: DeclarationReviver<P>["revive"]) => DeclarationReviver<P>Creates a filter reviver while inferring its payload type from payloadSchema.
Signature
declare const makeReviverFilter: <P>(id: string, payloadSchema: Schema.Decoder<P>, revive: FilterReviver<P>["revive"]) => FilterReviver<P>Creates a filter group reviver while inferring its payload type from payloadSchema.
Signature
declare const makeReviverFilterGroup: <P>(id: string, payloadSchema: Schema.Decoder<P>, revive: FilterGroupReviver<P>["revive"]) => FilterGroupReviver<P>Lowers the encoded side of an AST to a live representation document.
When to use
Use when you have one SchemaAST.AST and need a live Document for inspection, persistence, or compilation.
Details
Apply SchemaAST.toType to the AST first to lower its type side instead. The optional reference policy controls which
candidates are moved into the document's shared reference table. TypeScript-only
distinctions such as those added by Schema.brand are absent from the AST
and cannot be reconstructed from the resulting document.
See
- toRepresentations for multiple roots sharing one reference table
Signature
declare function toRepresentation(ast: AST, options?: ToRepresentationOptions): DocumentLowers one or more AST encoded sides in a shared reference environment.
When to use
Use when several AST roots must share identifiers, occurrence counts, recursion, and allocated reference names.
Details
Apply SchemaAST.toType to an AST first to lower its type side instead. The reference policy observes candidates from
every root before any representation is emitted.
See
- toRepresentation for a single AST root
Signature
declare function toRepresentations(asts: readonly [AST, AST], options?: ToRepresentationOptions): MultiDocumentDecoding
Decodes a persisted single-root representation document from JSON.
When to use
Use when reading a representation document from storage or transport before inspecting it or passing it to fromRepresentation.
Gotchas
Invalid documents throw a schema decoding error. Decoding does not reconstruct runtime callbacks.
See
- toJson for encoding a document
- fromRepresentation for reconstructing a runtime schema
- fromJsonMultiDocument for multiple roots sharing references
Signature
declare function fromJson(input: Json): DocumentDecodes a persisted multi-root representation document from JSON.
When to use
Use when reading multiple representation roots that share references before inspecting them or passing them to fromRepresentations.
Gotchas
Invalid documents throw a schema decoding error. Decoding does not reconstruct runtime callbacks.
See
- toJsonMultiDocument for encoding a multi-document
- fromRepresentations for reconstructing runtime schemas
- fromJson for a single root
Signature
declare function fromJsonMultiDocument(input: Json): MultiDocumentEncoding
Projects a live single-root representation document and encodes it as JSON.
When to use
Use when you need a stable JSON value for storage or transport after calling toRepresentation.
Gotchas
Generic annotations that are not JSON are omitted. Invalid persistence identities and unsupported structural values throw an Error containing their representation path.
See
- toRepresentation for constructing the live document
- toJsonMultiDocument for documents with multiple roots
Signature
declare function toJson(document: Document): JsonProjects a live multi-root representation document and encodes it as JSON.
When to use
Use when you need one JSON value for multiple live roots that share a reference environment.
Gotchas
The root order and shared reference keys are preserved, while non-JSON generic annotations are omitted.
See
- toRepresentations for constructing the live multi-document
- toJson for a single-root document
Signature
declare function toJsonMultiDocument(document: MultiDocument): JsonModels
The any keyword representation.
Signature
interface Any extends Keyword<"Any"> {}AnyReviver
typeA reviver erased only at collection boundaries.
Signature
type AnyReviver = Reviver<any>An array or tuple representation.
Signature
interface Arrays extends Keyword<"Arrays"> { readonly elements: readonly Array<Element>; readonly rest: readonly Array<Representation>;}Auxiliary source artifact emitted while generating schema code.
Signature
type Artifact = { readonly _tag: "Symbol"; readonly code: Code; readonly identifier: string;} | { readonly _tag: "Enum"; readonly code: Code; readonly identifier: string;} | { readonly _tag: "Import"; readonly importDeclaration: string;}A bigint representation.
Signature
interface BigInt extends Keyword<"BigInt"> {}A boolean representation.
Signature
interface Boolean extends Keyword<"Boolean"> {}A structural check.
Signature
type Check = Filter | FilterGroupCheckReviver
typeA check reviver.
Signature
type CheckReviver<P> = FilterReviver<P> | FilterGroupReviver<P>Runtime and TypeScript source generated for one schema.
Signature
interface Code { readonly runtime: string; readonly Type: string;}CodeDocument
interfaceGenerated schema code together with named references and auxiliary artifacts.
Signature
interface CodeDocument { readonly artifacts: readonly Array<Artifact>; readonly codes: readonly Array<Code>; readonly references: { readonly nonRecursives: readonly Array<{ readonly $ref: string; readonly code: Code; }>; readonly recursives: Readonly<Record<string, Code>>; };}Declaration
interfaceA custom opaque declaration.
Signature
interface Declaration { readonly _tag: "Declaration"; readonly annotations?: Annotations; readonly checks: readonly Array<Check>; readonly representation?: RepresentationAnnotation; readonly typeParameters: readonly Array<Representation>;}DeclarationReviver
interfaceReviver for a declaration.
Signature
interface DeclarationReviver<P> { readonly id: string; readonly payloadSchema: Decoder<P>; readonly revive: (input: { readonly annotations: Annotations | undefined; readonly payload: P; readonly typeParameters: readonly Array<Top>; }) => Top;}A single representation and its definitions.
Signature
interface Document { readonly references: References; readonly representation: Representation;}A tuple element.
Signature
interface Element { readonly annotations?: Annotations; readonly isOptional: boolean; readonly type: Representation;}An enum representation.
Details
Enum members are stored as native string or finite number values. Persistent codecs add an explicit type discriminator when encoding them.
Signature
interface Enum extends Keyword<"Enum"> { readonly enums: readonly Array<readonly [string, string | number]>;}An opaque leaf check.
Signature
interface Filter { readonly _tag: "Filter"; readonly aborted: boolean; readonly annotations?: Annotations; readonly representation?: CheckRepresentationAnnotation<Representation>;}FilterGroup
interfaceA non-empty group of checks.
Signature
interface FilterGroup { readonly _tag: "FilterGroup"; readonly annotations?: Annotations; readonly checks: readonly [Check, Check]; readonly representation?: CheckRepresentationAnnotation<Representation>;}FilterGroupReviver
interfaceReviver for a check group.
Signature
interface FilterGroupReviver<P> { readonly id: string; readonly payloadSchema: Decoder<P>; readonly revive: (input: { readonly annotations: Filter | undefined; readonly payload: P; readonly schemas: readonly Array<Top>; }) => FilterGroup<any>;}FilterReviver
interfaceReviver for a leaf check.
Signature
interface FilterReviver<P> { readonly id: string; readonly payloadSchema: Decoder<P>; readonly revive: (input: { readonly annotations: Filter | undefined; readonly payload: P; readonly schemas: readonly Array<Top>; }) => Filter<any>;}FromJsonSchemaOptions
interfaceOptions for importing JSON Schema Draft 2020-12 documents.
When to use
Use when you need to configure pattern handling or transform each JSON Schema node before translation.
Details
patterns controls pattern constraints reached during best-effort translation, including pattern, the keys of
patternProperties, and patterns nested in propertyNames:
"error"rejects the document and is the default."ignore"skips the constraint."apply"compiles and enforces the constraint with the runtime's native regular expression engine in Unicode mode. Patterns that cannot be compiled with theuflag are rejected with their source path.
Gotchas
Use patterns: "apply" only for trusted documents because regular expression evaluation may block for an unbounded
amount of time. patterns: "ignore" can admit values the source rejects, but can also reject previously valid
values inside oneOf when removing constraints makes multiple branches match.
Input documents are assumed to be valid Draft 2020-12 schemas and are not validated against the meta-schema.
Ignoring patternProperties also skips its value constraints and additionalProperties, because matching keys cannot
be determined without evaluating the patterns.
onEnter must return a JSON Schema object. Its result is used directly, and exceptions raised by the callback pass
through unchanged.
Signature
interface FromJsonSchemaOptions { readonly onEnter?: (schema: JsonSchema) => JsonSchema; readonly patterns?: "error" | "ignore" | "apply";}IndexSignature
interfaceAn index signature.
Signature
interface IndexSignature { readonly parameter: Representation; readonly type: Representation;}A literal representation.
Details
The live representation stores the native literal value. Persistent codecs add an explicit type discriminator when encoding it.
Signature
interface Literal extends Keyword<"Literal"> { readonly literal: LiteralValue;}MultiDocument
interfaceMultiple representations sharing definitions.
Signature
interface MultiDocument { readonly references: References; readonly representations: readonly [Representation, Representation];}The never keyword representation.
Signature
interface Never extends Keyword<"Never"> {}The null keyword representation.
Signature
interface Null extends Keyword<"Null"> {}A number representation.
Signature
interface Number extends Keyword<"Number"> {}ObjectKeyword
interfaceThe object keyword representation.
Signature
interface ObjectKeyword extends Keyword<"ObjectKeyword"> {}An object representation.
Signature
interface Objects extends Keyword<"Objects"> { readonly indexSignatures: readonly Array<IndexSignature>; readonly propertySignatures: readonly Array<PropertySignature>;}PropertySignature
interfaceA property signature.
Details
The live representation stores the native property key. Persistent codecs add an explicit type discriminator when encoding it.
Gotchas
Local symbols can be represented while the schema is live, but persistent codecs reject them because they cannot be reconstructed by identity.
Signature
interface PropertySignature { readonly annotations?: Annotations; readonly isMutable: boolean; readonly isOptional: boolean; readonly name: PropertyKey; readonly type: Representation;}A named reference.
Signature
interface Reference { readonly _tag: "Reference"; readonly $ref: string;}ReferencePolicy
typeFunction that chooses whether a representation candidate is emitted as a named reference.
When to use
Use when you need reference allocation based on schema identity, occurrence counts, identifiers, or another application-specific rule.
Details
Return a reference name to extract the candidate, or undefined to keep it inline. The policy is called once per
candidate after all occurrences have been counted. The identifier is the resolved identifier for the encoded AST,
including an Encoded suffix when an identifier is inherited from the source side of an encoding. If different
candidates request the same name, later names receive numeric suffixes in encounter order.
Gotchas
Recursive candidates always require a reference. When the policy returns undefined for one, the generator assigns
a synthetic name. Treat the input AST as immutable and keep the policy deterministic.
See
- ToRepresentationOptions for configuring representation generation
Signature
type ReferencePolicy = (input: ReferencePolicyInput) => string | undefinedReferencePolicyInput
interfaceInformation supplied to a reference policy for one representation candidate.
Signature
interface ReferencePolicyInput { readonly ast: AST; readonly identifier: string | undefined; readonly occurrences: number;}References
interfaceNamed representation definitions.
Signature
interface References { [$ref: string]: Representation;}Representation
typeThe structural schema representation.
Signature
type Representation = Declaration | Reference | Suspend | Null | Undefined | Void | Never | Unknown | Any | String | Number | Boolean | BigInt | Symbol | Literal | UniqueSymbol | ObjectKeyword | Enum | TemplateLiteral | Arrays | Objects | UnionA typed reviver.
Signature
type Reviver<P> = DeclarationReviver<P> | CheckReviver<P>A string representation.
Signature
interface String extends Keyword<"String"> {}A lazily resolved representation.
Signature
interface Suspend { readonly _tag: "Suspend"; readonly annotations?: Annotations; readonly checks: readonly []; readonly thunk: Representation;}A symbol representation.
Signature
interface Symbol extends Keyword<"Symbol"> {}TemplateLiteral
interfaceA template literal representation.
Signature
interface TemplateLiteral extends Keyword<"TemplateLiteral"> { readonly parts: readonly Array<Representation>;}The undefined keyword representation.
Signature
interface Undefined extends Keyword<"Undefined"> {}A union representation.
Signature
interface Union extends Keyword<"Union"> { readonly options?: UnionOptions; readonly types: readonly Array<Representation>;}UniqueSymbol
interfaceA unique symbol representation.
Details
Globally registered symbols have an exact JSON string representation. Local symbols have no JSON representation.
Signature
interface UniqueSymbol extends Keyword<"UniqueSymbol"> { readonly symbol: symbol;}The unknown keyword representation.
Signature
interface Unknown extends Keyword<"Unknown"> {}The void keyword representation.
Signature
interface Void extends Keyword<"Void"> {}Other
Schemas
Reviver for persisted Schema.BigDecimal declarations.
When to use
Use when reconstructing documents that may contain the Schema.BigDecimal schema.
See
- Schema.BigDecimal for the corresponding schema
Signature
declare const BigDecimalReviver: DeclarationReviver<null>Reviver for persisted Schema.ByteSize declarations.
Signature
declare const ByteSizeReviver: DeclarationReviver<null>Reviver for persisted CauseReason declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.CauseReason.
See
- Schema.CauseReason for creating the corresponding schema
Signature
declare const CauseReasonReviver: DeclarationReviver<null>Reviver for persisted Cause declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.Cause.
See
- Schema.Cause for creating the corresponding schema
Signature
declare const CauseReviver: DeclarationReviver<null>Reviver for persisted Schema.Chunk declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.Chunk.
See
- Schema.Chunk for creating the corresponding schema
Signature
declare const ChunkReviver: DeclarationReviver<null>Reviver for persisted Date declarations.
When to use
Use when reconstructing documents that may contain the Schema.Date schema.
See
- Schema.Date for the corresponding schema
Signature
declare const DateReviver: DeclarationReviver<null>Reviver for persisted Schema.DateTimeUtc declarations.
When to use
Use when reconstructing documents that may contain the Schema.DateTimeUtc schema.
See
- Schema.DateTimeUtc for the corresponding schema
Signature
declare const DateTimeUtcReviver: DeclarationReviver<null>Reviver for persisted Schema.DateTimeZoned declarations.
When to use
Use when reconstructing documents that may contain the Schema.DateTimeZoned schema.
See
- Schema.DateTimeZoned for the corresponding schema
Signature
declare const DateTimeZonedReviver: DeclarationReviver<null>Reviver for persisted Schema.Duration declarations.
When to use
Use when reconstructing documents that may contain the Schema.Duration schema.
See
- Schema.Duration for the corresponding schema
Signature
declare const DurationReviver: DeclarationReviver<null>Reviver for persisted Schema.ErrorInstance declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.ErrorInstance.
See
- Schema.ErrorInstance for creating the corresponding schema
Signature
declare const ErrorInstanceReviver: DeclarationReviver<ErrorRepresentationPayload>Reviver for persisted Exit declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.Exit.
See
- Schema.Exit for creating the corresponding schema
Signature
declare const ExitReviver: DeclarationReviver<null>Reviver for persisted File declarations.
When to use
Use when reconstructing documents that may contain the Schema.File schema.
See
- Schema.File for the corresponding schema
Signature
declare const FileReviver: DeclarationReviver<null>Reviver for persisted FormData declarations.
When to use
Use when reconstructing documents that may contain the Schema.FormData schema.
See
- Schema.FormData for the corresponding schema
Signature
declare const FormDataReviver: DeclarationReviver<null>Reviver for persisted Schema.Graph declarations.
Signature
declare const GraphReviver: DeclarationReviver<"directed" | "undirected">Reviver for persisted HashMap declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.HashMap.
See
- Schema.HashMap for creating the corresponding schema
Signature
declare const HashMapReviver: DeclarationReviver<null>Reviver for persisted HashSet declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.HashSet.
See
- Schema.HashSet for creating the corresponding schema
Signature
declare const HashSetReviver: DeclarationReviver<null>Reviver for persisted Json declarations.
When to use
Use when reconstructing documents that may contain the Schema.Json schema.
See
- Schema.Json for the corresponding immutable JSON schema
Signature
declare const JsonReviver: DeclarationReviver<null>Reviver for persisted MutableJson declarations.
When to use
Use when reconstructing documents that may contain the Schema.MutableJson schema.
See
- Schema.MutableJson for the corresponding mutable JSON schema
Signature
declare const MutableJsonReviver: DeclarationReviver<null>Reviver for persisted Option declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.Option.
See
- Schema.Option for creating the corresponding schema
Signature
declare const OptionReviver: DeclarationReviver<null>Reviver for persisted Schema.ReadonlyMap declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.ReadonlyMap.
See
- Schema.ReadonlyMap for creating the corresponding schema
Signature
declare const ReadonlyMapReviver: DeclarationReviver<null>Reviver for persisted Schema.ReadonlySet declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.ReadonlySet.
See
- Schema.ReadonlySet for creating the corresponding schema
Signature
declare const ReadonlySetReviver: DeclarationReviver<null>Reviver for persisted Schema.Redacted declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.Redacted.
See
- Schema.Redacted for creating the corresponding schema
Signature
declare const RedactedReviver: DeclarationReviver<RedactedRepresentationPayload>Reviver for persisted RegExp declarations.
When to use
Use when reconstructing documents that may contain the Schema.RegExp schema.
See
- Schema.RegExp for the corresponding schema
Signature
declare const RegExpReviver: DeclarationReviver<null>Reviver for persisted Schema.Result declarations.
When to use
Use when reconstructing documents that may contain schemas created by Schema.Result.
See
- Schema.Result for creating the corresponding schema
Signature
declare const ResultReviver: DeclarationReviver<null>Reviver for persisted Schema.TimeZoneNamed declarations.
When to use
Use when reconstructing documents that may contain the Schema.TimeZoneNamed schema.
See
- Schema.TimeZoneNamed for the corresponding schema
Signature
declare const TimeZoneNamedReviver: DeclarationReviver<null>Reviver for persisted Schema.TimeZoneOffset declarations.
When to use
Use when reconstructing documents that may contain the Schema.TimeZoneOffset schema.
See
- Schema.TimeZoneOffset for the corresponding schema
Signature
declare const TimeZoneOffsetReviver: DeclarationReviver<null>Reviver for persisted Schema.TimeZone declarations.
When to use
Use when reconstructing documents that may contain the Schema.TimeZone schema.
See
- Schema.TimeZone for the corresponding schema
Signature
declare const TimeZoneReviver: DeclarationReviver<null>Reviver for persisted Uint8Array declarations.
When to use
Use when reconstructing documents that may contain the Schema.Uint8Array schema.
See
- Schema.Uint8Array for the corresponding schema
Signature
declare const Uint8ArrayReviver: DeclarationReviver<null>Reviver for persisted URL declarations.
When to use
Use when reconstructing documents that may contain the Schema.URL schema.
See
- Schema.URL for the corresponding schema
Signature
declare const URLReviver: DeclarationReviver<null>Reviver for persisted URLSearchParams declarations.
When to use
Use when reconstructing documents that may contain the Schema.URLSearchParams schema.
See
- Schema.URLSearchParams for the corresponding schema
Signature
declare const URLSearchParamsReviver: DeclarationReviver<null>Transforming
Reconstructs a runtime schema from a representation document.
When to use
Use when you have decoded or constructed a document whose declaration and check annotations may require revivers.
Gotchas
Revivers are resolved locally by id; none are installed implicitly. Reviver results are used directly, and exceptions raised by a reviver pass through unchanged.
See
- fromJson for decoding a persisted document
- fromRepresentations for multiple roots sharing references
Signature
declare function fromRepresentation(document: Document, options: { readonly revivers: readonly Array<AnyReviver>;}): TopExample Restoring a persisted schema
import { Schema, SchemaRepresentation } from "effect"
const document = SchemaRepresentation.toRepresentation(Schema.Struct({ name: Schema.String }).ast)const persisted = SchemaRepresentation.toJson(document)const restored = SchemaRepresentation.fromJson(persisted)const schema = SchemaRepresentation.fromRepresentation(restored, { revivers: [] })const Person = Schema.make<Schema.Codec<{ readonly name: string }>>(schema.ast)
Schema.decodeUnknownSync(Person)({ name: "Ada" }) // => { name: "Ada" }Reconstructs multiple runtime schemas from a representation multi-document.
When to use
Use when multiple roots must be rebuilt in one shared reference environment.
Gotchas
Only references reachable from a root are revived. Revivers are resolved locally by id; none are installed implicitly.
See
- fromJsonMultiDocument for decoding a persisted multi-document
- fromRepresentation for a single root
Signature
declare function fromRepresentations(document: MultiDocument, options: { readonly revivers: readonly Array<AnyReviver>;}): readonly [Top, Top]Generates TypeScript source for live schema representations and their definitions.
When to use
Use when custom declarations and checks provide toCode callbacks and must be emitted without a central handler registry.
Gotchas
Opaque declarations and leaf checks require toCode callbacks. Callback results are used directly, and exceptions raised by a callback pass through unchanged.
Signature
declare function toCodeDocument(document: MultiDocument): CodeDocumentCompiles a live representation document to JSON Schema Draft 2020-12.
When to use
Use when you need JSON Schema output from a representation whose checks carry compiler annotations.
Details
The generated document is intended for preliminary validation. JSON Schema and Effect checks do not always have identical semantics, so the Effect decoder remains the final authority. Passing JSON Schema validation does not guarantee that Effect decoding will succeed.
A oneOf union exports as anyOf when any branch contains a known
approximation; otherwise it retains oneOf. Approximation propagates through
checks, nested schemas, check dependencies, and recursive references. Filters
without a toJsonSchema callback and opaque declarations are approximate.
Custom callbacks declare their result using ToJsonSchema.CheckOutput.
Gotchas
- Reference allocation is already fixed in the input
Document. The inheritedreferencePolicyoption has no effect here; pass it to toRepresentation when creating the document. - String length, RegExp flags, and decoded-object property checks can differ from Effect validation.
- Opaque declarations are represented by an unconstrained JSON Schema.
- Check callback results are used directly, and exceptions raised by a callback pass through unchanged. Callbacks must treat their input schemas as immutable. Each returned fragment must be a valid JSON Schema object graph and must not be mutated after the callback returns. The callback author is responsible for the emitted semantics.
- Local definition references returned by callbacks are resolved together with compiler-generated references.
Invalid JSON Pointer URI fragments throw an
Error. - The default
onExcessProperty: "ignore"matches the decoder default. UseonExcessProperty: "error"in both places when a closed object contract is required. - Record keys require an exact translation to a pattern before they can select
patternPropertiesvalues. Otherwise,"ignore"omits that index-signature constraint. In"error"mode, the compiler emits the generated key schemas underpropertyNamesand allows unmatched properties to satisfy any candidate index value schema. Exact selectors from other index signatures are retained, even when their value schemas are approximate.
See
- toJsonSchemaMultiDocument for multiple roots sharing definitions
Signature
declare function toJsonSchemaDocument(document: Document, options?: ToJsonSchemaOptions): Document<"draft-2020-12">Compiles multiple live representations to a shared JSON Schema Draft 2020-12 document.
When to use
Use when several representation roots must share the same JSON Schema definitions.
Details
Uses the same approximation tracking and oneOf and record-key fallbacks as
toJsonSchemaDocument, including across shared and recursive definitions.
Gotchas
- Reference allocation is already fixed in the input
MultiDocument. The inheritedreferencePolicyoption has no effect here; pass it to toRepresentations when creating the document. - Every definition is compiled, including definitions that are not reachable from a root. Check callbacks must treat
their input schemas as immutable. Each returned fragment must be a valid JSON Schema object graph and must not be
mutated after the callback returns. Local definition references returned by callbacks are resolved together with
compiler-generated references. Invalid JSON Pointer URI fragments throw an
Error. - String length, RegExp flags, decoded-object property checks, and custom check callbacks can differ from Effect validation, as described by toJsonSchemaDocument.
See
- toJsonSchemaDocument for a single root
Signature
declare function toJsonSchemaMultiDocument(document: MultiDocument, options?: ToJsonSchemaOptions): MultiDocument<"draft-2020-12">Wraps a single representation document as a multi-document with one root.
When to use
Use when an API such as toCodeDocument requires a MultiDocument.
Signature
declare function toMultiDocument(document: Document): MultiDocumentValidation
Reviver for persisted isBase64 checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isBase64.
See
- Schema.isBase64 for creating the corresponding check
Signature
declare const isBase64Reviver: FilterReviver<null>Reviver for persisted isBase64Url checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isBase64Url.
See
- Schema.isBase64Url for creating the corresponding check
Signature
declare const isBase64UrlReviver: FilterReviver<null>Reviver for persisted isBetweenBigInt checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isBetweenBigInt.
See
- Schema.isBetweenBigInt for creating the corresponding check
Signature
declare const isBetweenBigIntReviver: FilterReviver<{ readonly exclusiveMaximum?: true; readonly exclusiveMinimum?: true; readonly maximum: bigint; readonly minimum: bigint;}>Reviver for persisted isBetweenCodePoints checks.
See
- Schema.isBetweenCodePoints for creating the corresponding check
Signature
declare const isBetweenCodePointsReviver: FilterReviver<{ readonly maximum: number; readonly minimum: number;}>Reviver for persisted isBetweenDate checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isBetweenDate.
See
- Schema.isBetweenDate for creating the corresponding check
Signature
declare const isBetweenDateReviver: FilterReviver<{ readonly exclusiveMaximum?: true; readonly exclusiveMinimum?: true; readonly maximum: globalThis.Date; readonly minimum: globalThis.Date;}>Reviver for persisted isBetweenLength checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isBetweenLength.
See
- Schema.isBetweenLength for creating the corresponding check
Signature
declare const isBetweenLengthReviver: FilterReviver<{ readonly maximum: number; readonly minimum: number;}>Reviver for persisted isBetweenProperties checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isBetweenProperties.
See
- Schema.isBetweenProperties for creating the corresponding check
Signature
declare const isBetweenPropertiesReviver: FilterReviver<{ readonly maximum: number; readonly minimum: number;}>Reviver for persisted isBetween checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isBetween.
See
- Schema.isBetween for creating the corresponding check
Signature
declare const isBetweenReviver: FilterReviver<{ readonly exclusiveMaximum?: true; readonly exclusiveMinimum?: true; readonly maximum: number; readonly minimum: number;}>Reviver for persisted isBetweenSize checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isBetweenSize.
See
- Schema.isBetweenSize for creating the corresponding check
Signature
declare const isBetweenSizeReviver: FilterReviver<{ readonly maximum: number; readonly minimum: number;}>Reviver for persisted isCapitalized checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isCapitalized.
See
- Schema.isCapitalized for creating the corresponding check
Signature
declare const isCapitalizedReviver: FilterReviver<null>Reviver for persisted isEndingWith checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isEndingWith.
See
- Schema.isEndingWith for creating the corresponding check
Signature
declare const isEndingWithReviver: FilterReviver<{ readonly endsWith: string;}>Reviver for persisted isFinite checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isFinite.
See
- Schema.isFinite for creating the corresponding check
Signature
declare const isFiniteReviver: FilterReviver<null>Reviver for persisted isGreaterThanBigInt checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isGreaterThanBigInt.
See
- Schema.isGreaterThanBigInt for creating the corresponding check
Signature
declare const isGreaterThanBigIntReviver: FilterReviver<{ readonly exclusiveMinimum: bigint;}>Reviver for persisted isGreaterThanDate checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isGreaterThanDate.
See
- Schema.isGreaterThanDate for creating the corresponding check
Signature
declare const isGreaterThanDateReviver: FilterReviver<{ readonly exclusiveMinimum: globalThis.Date;}>Reviver for persisted isGreaterThanOrEqualToBigInt checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isGreaterThanOrEqualToBigInt.
See
- Schema.isGreaterThanOrEqualToBigInt for creating the corresponding check
Signature
declare const isGreaterThanOrEqualToBigIntReviver: FilterReviver<{ readonly minimum: bigint;}>Reviver for persisted isGreaterThanOrEqualToDate checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isGreaterThanOrEqualToDate.
See
- Schema.isGreaterThanOrEqualToDate for creating the corresponding check
Signature
declare const isGreaterThanOrEqualToDateReviver: FilterReviver<{ readonly minimum: globalThis.Date;}>Reviver for persisted isGreaterThanOrEqualTo checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isGreaterThanOrEqualTo.
See
- Schema.isGreaterThanOrEqualTo for creating the corresponding check
Signature
declare const isGreaterThanOrEqualToReviver: FilterReviver<{ readonly minimum: number;}>Reviver for persisted isGreaterThan checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isGreaterThan.
See
- Schema.isGreaterThan for creating the corresponding check
Signature
declare const isGreaterThanReviver: FilterReviver<{ readonly exclusiveMinimum: number;}>Reviver for persisted isGUID checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isGUID.
See
- Schema.isGUID for creating the corresponding check
Signature
declare const isGUIDReviver: FilterReviver<null>Reviver for persisted isIncluding checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isIncluding.
See
- Schema.isIncluding for creating the corresponding check
Signature
declare const isIncludingReviver: FilterReviver<{ readonly includes: string;}>Reviver for persisted isInt checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isInt.
See
- Schema.isInt for creating the corresponding check
Signature
declare const isIntReviver: FilterReviver<null>Reviver for persisted isLessThanBigInt checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isLessThanBigInt.
See
- Schema.isLessThanBigInt for creating the corresponding check
Signature
declare const isLessThanBigIntReviver: FilterReviver<{ readonly exclusiveMaximum: bigint;}>Reviver for persisted isLessThanDate checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isLessThanDate.
See
- Schema.isLessThanDate for creating the corresponding check
Signature
declare const isLessThanDateReviver: FilterReviver<{ readonly exclusiveMaximum: globalThis.Date;}>Reviver for persisted isLessThanOrEqualToBigInt checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isLessThanOrEqualToBigInt.
See
- Schema.isLessThanOrEqualToBigInt for creating the corresponding check
Signature
declare const isLessThanOrEqualToBigIntReviver: FilterReviver<{ readonly maximum: bigint;}>Reviver for persisted isLessThanOrEqualToDate checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isLessThanOrEqualToDate.
See
- Schema.isLessThanOrEqualToDate for creating the corresponding check
Signature
declare const isLessThanOrEqualToDateReviver: FilterReviver<{ readonly maximum: globalThis.Date;}>Reviver for persisted isLessThanOrEqualTo checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isLessThanOrEqualTo.
See
- Schema.isLessThanOrEqualTo for creating the corresponding check
Signature
declare const isLessThanOrEqualToReviver: FilterReviver<{ readonly maximum: number;}>Reviver for persisted isLessThan checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isLessThan.
See
- Schema.isLessThan for creating the corresponding check
Signature
declare const isLessThanReviver: FilterReviver<{ readonly exclusiveMaximum: number;}>Reviver for persisted isLowercased checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isLowercased.
See
- Schema.isLowercased for creating the corresponding check
Signature
declare const isLowercasedReviver: FilterReviver<null>Reviver for persisted isMaxCodePoints checks.
See
- Schema.isMaxCodePoints for creating the corresponding check
Signature
declare const isMaxCodePointsReviver: FilterReviver<{ readonly maxCodePoints: number;}>Reviver for persisted isMaxLength checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isMaxLength.
See
- Schema.isMaxLength for creating the corresponding check
Signature
declare const isMaxLengthReviver: FilterReviver<{ readonly maxLength: number;}>Reviver for persisted isMaxProperties checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isMaxProperties.
See
- Schema.isMaxProperties for creating the corresponding check
Signature
declare const isMaxPropertiesReviver: FilterReviver<{ readonly maxProperties: number;}>Reviver for persisted isMaxSize checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isMaxSize.
See
- Schema.isMaxSize for creating the corresponding check
Signature
declare const isMaxSizeReviver: FilterReviver<{ readonly maxSize: number;}>Reviver for persisted isMinCodePoints checks.
See
- Schema.isMinCodePoints for creating the corresponding check
Signature
declare const isMinCodePointsReviver: FilterReviver<{ readonly minCodePoints: number;}>Reviver for persisted isMinLength checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isMinLength.
See
- Schema.isMinLength for creating the corresponding check
Signature
declare const isMinLengthReviver: FilterReviver<{ readonly minLength: number;}>Reviver for persisted isMinProperties checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isMinProperties.
See
- Schema.isMinProperties for creating the corresponding check
Signature
declare const isMinPropertiesReviver: FilterReviver<{ readonly minProperties: number;}>Reviver for persisted isMinSize checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isMinSize.
See
- Schema.isMinSize for creating the corresponding check
Signature
declare const isMinSizeReviver: FilterReviver<{ readonly minSize: number;}>Reviver for persisted isMultipleOf checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isMultipleOf.
See
- Schema.isMultipleOf for creating the corresponding check
Signature
declare const isMultipleOfReviver: FilterReviver<{ readonly divisor: number;}>Reviver for persisted isPattern checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isPattern.
See
- Schema.isPattern for creating the corresponding check
Signature
declare const isPatternReviver: FilterReviver<{ readonly flags: string; readonly source: string;}>Reviver for persisted isPropertyNames checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isPropertyNames.
See
- Schema.isPropertyNames for creating the corresponding check
Signature
declare const isPropertyNamesReviver: FilterReviver<null>Reviver for persisted isStartingWith checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isStartingWith.
See
- Schema.isStartingWith for creating the corresponding check
Signature
declare const isStartingWithReviver: FilterReviver<{ readonly startsWith: string;}>Reviver for persisted isStringBigInt checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isStringBigInt.
See
- Schema.isStringBigInt for creating the corresponding check
Signature
declare const isStringBigIntReviver: FilterReviver<null>Reviver for persisted isStringFinite checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isStringFinite.
See
- Schema.isStringFinite for creating the corresponding check
Signature
declare const isStringFiniteReviver: FilterReviver<null>Reviver for persisted isStringSymbol checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isStringSymbol.
See
- Schema.isStringSymbol for creating the corresponding check
Signature
declare const isStringSymbolReviver: FilterReviver<null>Reviver for persisted isTrimmed checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isTrimmed.
See
- Schema.isTrimmed for creating the corresponding check
Signature
declare const isTrimmedReviver: FilterReviver<null>Reviver for persisted isULID checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isULID.
See
- Schema.isULID for creating the corresponding check
Signature
declare const isULIDReviver: FilterReviver<null>Reviver for persisted isUncapitalized checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isUncapitalized.
See
- Schema.isUncapitalized for creating the corresponding check
Signature
declare const isUncapitalizedReviver: FilterReviver<null>Reviver for persisted isUniqueKey checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isUniqueKey.
See
- Schema.isUniqueKey for creating the corresponding check
Signature
declare const isUniqueKeyReviver: FilterReviver<null>Reviver for persisted isUnique checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isUnique.
See
- Schema.isUnique for creating the corresponding check
Signature
declare const isUniqueReviver: FilterReviver<null>Reviver for persisted isUppercased checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isUppercased.
See
- Schema.isUppercased for creating the corresponding check
Signature
declare const isUppercasedReviver: FilterReviver<null>Reviver for persisted isUUID checks.
When to use
Use when reconstructing documents that may contain checks created by Schema.isUUID.
See
- Schema.isUUID for creating the corresponding check
Signature
declare const isUUIDReviver: FilterReviver<{ readonly version: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | null;}>