Schema.Codec<MultiDocument, Schema.Json, never, never>Schema for MultiDocument values encoded as JSON.
export const const MultiDocumentFromJson: Schema.Codec<
MultiDocument,
Schema.Json
>
const MultiDocumentFromJson: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<MultiDocument, any>) => Schema.Codec<MultiDocument, Schema.Json, never, never>;
annotateKey: (annotations: Schema.Annotations.Key<MultiDocument>) => Schema.Codec<MultiDocument, Schema.Json, never, never>;
check: (checks_0: SchemaAST.Check<MultiDocument>, ...checks: Array<SchemaAST.Check<MultiDocument>>) => Schema.Codec<MultiDocument, Schema.Json, never, never>;
rebuild: (ast: SchemaAST.AST) => Schema.Codec<MultiDocument, Schema.Json, never, never>;
make: (input: unknown, options?: MakeOptions) => SchemaRepresentation.MultiDocument;
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<SchemaRepresentation.MultiDocument>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<SchemaRepresentation.MultiDocument, 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 for MultiDocument values encoded as JSON.
MultiDocumentFromJson: import SchemaSchema.interface Codec<out T, out E = T, out RD = never, out RE = never>Namespace of type-level helpers for
Codec
.
A schema that tracks the decoded type T, the encoded type E, and the
Effect services required during decoding (RD) and encoding (RE).
Details
Use Codec<T, E, RD, RE> when you need to preserve full type information
about a schema — both what it decodes to and what it serializes from/to.
Most concrete schemas produced by this module implement Codec.
For APIs that only need one direction, prefer the narrower views:
Decoder
<T, RD> — decode-only
Encoder
<E, RE> — encode-only
Schema
<T> — type-only (no encoded representation)
Example (Accepting a codec that decodes to number from string)
import { Schema } from "effect"
declare function serialize<T>(codec: Schema.Codec<T, string>): string
serialize(Schema.NumberFromString) // ok — decodes number, encoded as string
Codec<type MultiDocument = {
readonly representations: readonly [
Representation,
...Array<Representation>
]
readonly references: References
}
One or more
Representation
s sharing a common
References
map.
When to use
Use when you use
fromASTs
to create this from multiple Schema ASTs,
toCodeDocument
to generate TypeScript code, and
toJsonSchemaMultiDocument
to convert to JSON Schema.
MultiDocument, import SchemaSchema.type Json =
| string
| number
| boolean
| Schema.JsonArray
| Schema.JsonObject
| null
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> = import SchemaSchema.function toCodecJson<
S extends Constraint
>(schema: S): toCodecJson<S>
Derives a canonical JSON codec from a schema. The encoded form is Json, and
decoding produces the schema's Type.
toCodecJson(const $MultiDocument: Schema.Struct<{
readonly representations: Schema.NonEmptyArray<$Representation>
readonly references: Schema.$Record<
Schema.String,
$Representation
>
}>
const $MultiDocument: {
Type: Struct.Type<Fields>;
Encoded: Struct.Encoded<Fields>;
DecodingServices: Struct.DecodingServices<Fields>;
EncodingServices: Struct.EncodingServices<Fields>;
Iso: Struct.Iso<Fields>;
fields: Fields;
mapFields: (f: (fields: { readonly representations: Schema.NonEmptyArray<$Representation>; readonly references: Schema.$Record<Schema.String, $Representation> }) => To, options?: { readonly unsafePreserveChecks?: boolean | undefined } | undefined) =>…;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<Schema.Struct.ReadonlySide<{ readonly representations: Schema.NonEmptyArray<$Representation>; readonly references: Schema.$Record<Schema.String, $Representation>; }, 'Type'>, readonly []>) => Schema.…;
annotateKey: (annotations: Schema.Annotations.Key<Schema.Struct.ReadonlySide<{ readonly representations: Schema.NonEmptyArray<$Representation>; readonly references: Schema.$Record<Schema.String, $Representation> }, 'Type'>>) => Schema.Struct<{ readonly…;
check: (checks_0: SchemaAST.Check<Schema.Struct.ReadonlySide<{ readonly representations: Schema.NonEmptyArray<$Representation>; readonly references: Schema.$Record<Schema.String, $Representation> }, 'Type'>>, ...checks: Array<SchemaAST.Check<Sche…;
rebuild: (ast: SchemaAST.Objects) => Schema.Struct<{ readonly representations: Schema.NonEmptyArray<$Representation>; readonly references: Schema.$Record<Schema.String, $Representation> }>;
make: (input: Struct.ReadonlyMakeIn<{ readonly representations: NonEmptyArray<SchemaRepresentation.$Representation>; readonly references: $Record<String, SchemaRepresentation.$Representation> }>, options?: MakeOptions) => Struct.ReadonlySide<{ r…;
makeOption: (input: Struct.ReadonlyMakeIn<{ readonly representations: NonEmptyArray<SchemaRepresentation.$Representation>; readonly references: $Record<String, SchemaRepresentation.$Representation> }>, options?: MakeOptions) => Option_.Option<Struct.R…;
makeEffect: (input: Struct.ReadonlyMakeIn<{ readonly representations: NonEmptyArray<SchemaRepresentation.$Representation>; readonly references: $Record<String, SchemaRepresentation.$Representation> }>, options?: MakeOptions) => Effect.Effect<Struct.Re…;
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 for
MultiDocument
.
$MultiDocument)