Schema.Union<
readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.BigInt]
>Schema for the literal value types allowed in a Literal node (string, finite number, boolean, or bigint).
export const const $LiteralValue: Schema.Union<
readonly [
Schema.String,
Schema.Finite,
Schema.Boolean,
Schema.BigInt
]
>
const $LiteralValue: {
Type: { [K in keyof Members]: Members[K]["Type"]; }[number];
Encoded: { [K in keyof Members]: Members[K]["Encoded"]; }[number];
DecodingServices: { [K in keyof Members]: Members[K]["DecodingServices"]; }[number];
EncodingServices: { [K in keyof Members]: Members[K]["EncodingServices"]; }[number];
Iso: { [K in keyof Members]: Members[K]["Iso"]; }[number];
members: Members;
mapMembers: (f: (members: readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.BigInt]) => To, options?: { readonly unsafePreserveChecks?: boolean | undefined } | undefined) => Schema.Union<{ [K in keyof Readonly<To>]: Readonly<To>[K]; }>;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<string | number | bigint | boolean, readonly []>) => Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.BigInt]>;
annotateKey: (annotations: Schema.Annotations.Key<string | number | bigint | boolean>) => Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.BigInt]>;
check: (checks_0: SchemaAST.Check<string | number | bigint | boolean>, ...checks: Array<SchemaAST.Check<string | number | bigint | boolean>>) => Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.BigInt]>;
rebuild: (ast: SchemaAST.Union<SchemaAST.String | SchemaAST.Number | SchemaAST.Boolean | SchemaAST.BigInt>) => Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.BigInt]>;
make: (input: string | number | bigint | boolean, options?: MakeOptions) => string | number | bigint | boolean;
makeOption: (input: string | number | bigint | boolean, options?: MakeOptions) => Option_.Option<string | number | bigint | boolean>;
makeEffect: (input: string | number | bigint | boolean, options?: MakeOptions) => Effect.Effect<string | number | bigint | boolean, 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 the literal value types allowed in a
Literal
node
(string, finite number, boolean, or bigint).
$LiteralValue = import SchemaSchema.function Union<
Members extends ReadonlyArray<Constraint>
>(
members: Members,
options?: { mode?: "anyOf" | "oneOf" }
): Union<Members>
Creates a union schema from an array of member schemas. Members are tested in
order; the first match is returned.
Details
Optionally, specify mode:
"anyOf" (default) — matches if any member matches.
"oneOf" — matches if exactly one member matches.
Example (Defining a string or number union)
import { Schema } from "effect"
const schema = Schema.Union([Schema.String, Schema.Number])
Schema.decodeUnknownSync(schema)("hello") // "hello"
Schema.decodeUnknownSync(schema)(42) // 42
Union([
import SchemaSchema.const String: Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: SchemaAST.Check<string>, ...checks: Array<SchemaAST.Check<string>>) => Schema.String;
rebuild: (ast: SchemaAST.String) => Schema.String;
make: (input: string, options?: MakeOptions) => string;
makeOption: (input: string, options?: MakeOptions) => Option_.Option<string>;
makeEffect: (input: string, options?: MakeOptions) => Effect.Effect<string, 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
String
.
Schema for string values. Validates that the input is typeof "string".
String,
import SchemaSchema.const Finite: Finiteconst Finite: {
Rebuild: Finite;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<number, readonly []>) => Schema.Finite;
annotateKey: (annotations: Schema.Annotations.Key<number>) => Schema.Finite;
check: (checks_0: SchemaAST.Check<number>, ...checks: Array<SchemaAST.Check<number>>) => Schema.Finite;
rebuild: (ast: SchemaAST.Number) => Schema.Finite;
make: (input: number, options?: MakeOptions) => number;
makeOption: (input: number, options?: MakeOptions) => Option_.Option<number>;
makeEffect: (input: number, options?: MakeOptions) => Effect.Effect<number, 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
Finite
.
Schema for finite numbers, rejecting NaN, Infinity, and -Infinity.
Finite,
import SchemaSchema.const Boolean: Booleanconst Boolean: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<boolean, readonly []>) => Schema.Boolean;
annotateKey: (annotations: Schema.Annotations.Key<boolean>) => Schema.Boolean;
check: (checks_0: SchemaAST.Check<boolean>, ...checks: Array<SchemaAST.Check<boolean>>) => Schema.Boolean;
rebuild: (ast: SchemaAST.Boolean) => Schema.Boolean;
make: (input: boolean, options?: MakeOptions) => boolean;
makeOption: (input: boolean, options?: MakeOptions) => Option_.Option<boolean>;
makeEffect: (input: boolean, options?: MakeOptions) => Effect.Effect<boolean, 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
Boolean
.
Schema for boolean values. Validates that the input is typeof "boolean".
When to use
Use to validate values that are already JavaScript booleans.
Boolean,
import SchemaSchema.const BigInt: BigIntconst BigInt: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<bigint, readonly []>) => Schema.BigInt;
annotateKey: (annotations: Schema.Annotations.Key<bigint>) => Schema.BigInt;
check: (checks_0: SchemaAST.Check<bigint>, ...checks: Array<SchemaAST.Check<bigint>>) => Schema.BigInt;
rebuild: (ast: SchemaAST.BigInt) => Schema.BigInt;
make: (input: bigint, options?: MakeOptions) => bigint;
makeOption: (input: bigint, options?: MakeOptions) => Option_.Option<bigint>;
makeEffect: (input: bigint, options?: MakeOptions) => Effect.Effect<bigint, 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
BigInt
.
Schema for bigint values. Validates that the input is typeof "bigint".
When to use
Use when the input is already a bigint and the schema should validate and
preserve bigint values without parsing from another representation.
BigInt
]).Bottom<unknown, unknown, unknown, unknown, Union<...>, Union<...>, ... 8 more ..., "required">.annotate(annotations: Schema.Annotations.Bottom<string | number | bigint | boolean, readonly []>): Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.BigInt]>annotate({ Annotations.Bottom<T, TypeParameters extends ReadonlyArray<Constraint>>.identifier?: string | undefinedStable identifier for this schema node.
Details
Identifiers are used by schema tooling, including JSON Schema
generation, to name references. The default formatter also uses
identifier as the expected label for type-level failures, such as
Expected UserId, got null.
identifier does not name a failed filter or refinement. If the base
type matches and a filter fails, put expected or message on the
filter/refinement instead.
identifier: "LiteralValue" })