<Value extends Constraint>(value: Value): $ReadonlySet<Value>Schema for readonly sets whose values conform to the provided element schema.
export function function ReadonlySet<
Value extends Constraint
>(value: Value): $ReadonlySet<Value>
Schema for readonly sets whose values conform to the provided element schema.
ReadonlySet<function (type parameter) Value in ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value>Value extends Constraint>(value: Value extends Constraintvalue: function (type parameter) Value in ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value>Value): interface $ReadonlySet<Value extends Constraint>Type-level representation returned by
ReadonlySet
.
$ReadonlySet<function (type parameter) Value in ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value>Value> {
const const schema: declareConstructor<
ReadonlySet<Value["Type"]>,
ReadonlySet<Value["Encoded"]>,
readonly [Value],
ReadonlySetIso<Value>
>
const schema: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<ReadonlySet<Value['Type']>, readonly [Value]>) => declareConstructor<ReadonlySet<Value['Type']>, ReadonlySet<Value['Encoded']>, readonly [Value], ReadonlySetIso<Value>>;
annotateKey: (annotations: Annotations.Key<ReadonlySet<Value['Type']>>) => declareConstructor<ReadonlySet<Value['Type']>, ReadonlySet<Value['Encoded']>, readonly [Value], ReadonlySetIso<Value>>;
check: (checks_0: SchemaAST.Check<ReadonlySet<Value['Type']>>, ...checks: Array<SchemaAST.Check<ReadonlySet<Value['Type']>>>) => declareConstructor<ReadonlySet<Value['Type']>, ReadonlySet<Value['Encoded']>, readonly [Value], ReadonlySetIso<Value>>;
rebuild: (ast: SchemaAST.Declaration) => declareConstructor<ReadonlySet<Value['Type']>, ReadonlySet<Value['Encoded']>, readonly [Value], ReadonlySetIso<Value>>;
make: (input: ReadonlySet<Value['Type']>, options?: MakeOptions) => ReadonlySet<Value['Type']>;
makeOption: (input: ReadonlySet<Value['Type']>, options?: MakeOptions) => Option_.Option<ReadonlySet<Value['Type']>>;
makeEffect: (input: ReadonlySet<Value['Type']>, options?: MakeOptions) => Effect.Effect<ReadonlySet<Value['Type']>, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
schema = function declareConstructor<
T,
E = T,
Iso = T
>(): <
TypeParameters extends ReadonlyArray<Constraint>
>(
typeParameters: TypeParameters,
run: (typeParameters: {
readonly [K in keyof TypeParameters]: Codec<
TypeParameters[K]["Type"],
TypeParameters[K]["Encoded"]
>
}) => (
u: unknown,
self: SchemaAST.Declaration,
options: SchemaAST.ParseOptions
) => Effect.Effect<T, SchemaIssue.Issue>,
annotations?: Annotations.Declaration<
T,
TypeParameters
>
) => declareConstructor<T, E, TypeParameters, Iso>
Creates a schema for a parametric type (a generic container such as
Array<A>, Option<A>, etc.) by accepting a list of type-parameter schemas
and a decoder factory.
When to use
Use when you are defining a schema for a generic container whose validation
depends on one or more type-parameter schemas.
Details
The outer call declareConstructor<T, E, Iso>() fixes the decoded type T,
the encoded type E, and the optional iso type. The inner call receives:
typeParameters — the concrete schemas for each type variable
run — a factory that, given resolved codecs for each type parameter,
returns a parsing function (u, ast, options) => Effect<T, Issue>
annotations — optional metadata
declareConstructor<
module globalThisglobalThis.interface ReadonlySet<T>ReadonlySet<function (type parameter) Value in ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value>Value["Type"]>,
module globalThisglobalThis.interface ReadonlySet<T>ReadonlySet<function (type parameter) Value in ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value>Value["Encoded"]>,
type ReadonlySetIso<
Value extends Constraint
> = readonly Value["Iso"][]
Iso representation used for ReadonlySet schemas: an array of element values
using the element schema's Iso type.
ReadonlySetIso<function (type parameter) Value in ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value>Value>
>()(
[value: Value extends Constraintvalue],
([value: Codec<
Value["Type"],
Value["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<Value['Type'], any>) => Codec<Value['Type'], Value['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<Value['Type']>) => Codec<Value['Type'], Value['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<Value['Type']>, ...checks: Array<SchemaAST.Check<Value['Type']>>) => Codec<Value['Type'], Value['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<Value['Type'], Value['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => Value['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<Value['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<Value['Type'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
value]) => {
const const array: $Array<
Codec<
Value["Type"],
Value["Encoded"],
never,
never
>
>
const array: {
Type: ReadonlyArray<S["Type"]>;
Encoded: ReadonlyArray<S["Encoded"]>;
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: ReadonlyArray<S["Iso"]>;
value: S;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Annotations.Bottom<ReadonlyArray<Value['Type']>, readonly []>) => $Array<Codec<Value['Type'], Value['Encoded'], never, never>>;
annotateKey: (annotations: Annotations.Key<ReadonlyArray<Value['Type']>>) => $Array<Codec<Value['Type'], Value['Encoded'], never, never>>;
check: (checks_0: SchemaAST.Check<ReadonlyArray<Value['Type']>>, ...checks: Array<SchemaAST.Check<ReadonlyArray<Value['Type']>>>) => $Array<Codec<Value['Type'], Value['Encoded'], never, never>>;
rebuild: (ast: SchemaAST.Arrays) => $Array<Codec<Value['Type'], Value['Encoded'], never, never>>;
make: (input: ReadonlyArray<unknown>, options?: MakeOptions) => ReadonlyArray<Value['Type']>;
makeOption: (input: ReadonlyArray<unknown>, options?: MakeOptions) => Option_.Option<ReadonlyArray<Value['Type']>>;
makeEffect: (input: ReadonlyArray<unknown>, options?: MakeOptions) => Effect.Effect<ReadonlyArray<Value['Type']>, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
array = const ArraySchema: ArrayLambda
<Codec<Value["Type"], Value["Encoded"], never, never>>(self: Codec<Value["Type"], Value["Encoded"], never, never>) => $Array<Codec<Value["Type"], Value["Encoded"], never, never>>
ArraySchema(value: Codec<
Value["Type"],
Value["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<Value['Type'], any>) => Codec<Value['Type'], Value['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<Value['Type']>) => Codec<Value['Type'], Value['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<Value['Type']>, ...checks: Array<SchemaAST.Check<Value['Type']>>) => Codec<Value['Type'], Value['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<Value['Type'], Value['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => Value['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<Value['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<Value['Type'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
value)
return (input: unknowninput, ast: SchemaAST.Declaration(parameter) ast: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, options: SchemaAST.ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options) => {
if (input: unknowninput instanceof module globalThisglobalThis.var Set: SetConstructorSet) {
return import EffectEffect.mapBothEager(
import SchemaParserSchemaParser.function decodeUnknownEffect<
S extends Schema.Constraint
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Type"],
SchemaIssue.Issue,
S["DecodingServices"]
>
Creates an effectful decoder for unknown input.
When to use
Use when you need to decode untyped boundary input in an Effect whose
failure channel is SchemaIssue.Issue, while preserving transformations
and service requirements.
Details
The returned function succeeds with the schema's decoded Type or fails with a
SchemaIssue.Issue. Decoding service requirements are preserved in the returned
Effect. Parse options may be provided when creating the decoder and overridden
when applying it.
decodeUnknownEffect(const array: $Array<
Codec<
Value["Type"],
Value["Encoded"],
never,
never
>
>
const array: {
Type: ReadonlyArray<S["Type"]>;
Encoded: ReadonlyArray<S["Encoded"]>;
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: ReadonlyArray<S["Iso"]>;
value: S;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Annotations.Bottom<ReadonlyArray<Value['Type']>, readonly []>) => $Array<Codec<Value['Type'], Value['Encoded'], never, never>>;
annotateKey: (annotations: Annotations.Key<ReadonlyArray<Value['Type']>>) => $Array<Codec<Value['Type'], Value['Encoded'], never, never>>;
check: (checks_0: SchemaAST.Check<ReadonlyArray<Value['Type']>>, ...checks: Array<SchemaAST.Check<ReadonlyArray<Value['Type']>>>) => $Array<Codec<Value['Type'], Value['Encoded'], never, never>>;
rebuild: (ast: SchemaAST.Arrays) => $Array<Codec<Value['Type'], Value['Encoded'], never, never>>;
make: (input: ReadonlyArray<unknown>, options?: MakeOptions) => ReadonlyArray<Value['Type']>;
makeOption: (input: ReadonlyArray<unknown>, options?: MakeOptions) => Option_.Option<ReadonlyArray<Value['Type']>>;
makeEffect: (input: ReadonlyArray<unknown>, options?: MakeOptions) => Effect.Effect<ReadonlyArray<Value['Type']>, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
array)([...input: Set<any>input], options: SchemaAST.ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options),
{
onSuccess: (
array: ReadonlyArray<Value["Type"]>
) => Set<Value["Type"]>
onSuccess: (array: readonly Value["Type"][]array: interface ReadonlyArray<T>ReadonlyArray<function (type parameter) Value in ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value>Value["Type"]>) => new module globalThisglobalThis.var Set: SetConstructor
new <Value["Type"]>(iterable?: Iterable<Value["Type"]> | null | undefined) => Set<Value["Type"]> (+1 overload)
Set(array: readonly Value["Type"][]array),
onFailure: (issue: any) => SchemaIssue.CompositeonFailure: (issue: SchemaIssue.Issueissue) =>
new import SchemaIssueSchemaIssue.constructor Composite(ast: SchemaAST.AST, actual: StandardJSONSchemaV1<unknown>, issues: readonly [SchemaIssue.Issue, ...Array<SchemaIssue.Issue>]): SchemaIssue.CompositeRepresents a schema issue that groups multiple child issues under a single schema node.
When to use
Use when you need to walk the issue tree for struct/tuple schemas that collect
all field errors rather than failing on the first.
Details
issues is a non-empty readonly array (at least one child).
actual is Option.some(value) when the input was present, or
Option.none() when absent.
- Formatters flatten
Composite by recursing into each child.
Composite(ast: SchemaAST.Declaration(parameter) ast: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, import Option_Option_.some(input: Set<any>input), [new import SchemaIssueSchemaIssue.constructor Pointer(path: ReadonlyArray<PropertyKey>, issue: SchemaIssue.Issue): SchemaIssue.PointerWraps an inner
Issue
with a property-key path, indicating where in
a nested structure the error occurred.
When to use
Use when you need to walk the issue tree to accumulate path segments for error
reporting.
Details
path is an array of property keys (strings, numbers, or symbols).
- Has no
actual value —
getActual
returns Option.none().
- Formatters concatenate nested
Pointer paths into a single path like
["a"]["b"][0].
Pointer(["values"], issue: SchemaIssue.Issueissue)])
}
)
}
return import EffectEffect.fail(new import SchemaIssueSchemaIssue.constructor InvalidType(ast: SchemaAST.AST, actual: StandardJSONSchemaV1<unknown>): SchemaIssue.InvalidTypeRepresents a schema issue produced when the runtime type of the input does not match the type
expected by the schema (e.g. got null when string was expected).
When to use
Use when you need to detect basic type mismatches, such as a wrong primitive
or null where an object was expected.
Details
ast is the schema node that expected a different type.
actual is Option.some(value) when the input was present, or
Option.none() when no value was provided.
- The default formatter renders this as
"Expected <type>, got <actual>".
Example (Formatting output)
import { Schema } from "effect"
try {
Schema.decodeUnknownSync(Schema.String)(42)
} catch (e) {
if (Schema.isSchemaError(e)) {
console.log(String(e.issue))
// "Expected string, got 42"
}
}
InvalidType(ast: SchemaAST.Declaration(parameter) ast: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, import Option_Option_.some(input: unknowninput)))
}
},
{
Annotations.Declaration<ReadonlySet<Value["Type"]>, readonly [Value]>.typeConstructor?: {
readonly [key: string]: unknown;
readonly _tag: string;
} | undefined
typeConstructor: {
_tag: string_tag: "ReadonlySet"
},
Annotations.Declaration<ReadonlySet<Value["Type"]>, readonly [Value]>.generation?: {
readonly runtime: string;
readonly Type: string;
readonly Encoded?: string | undefined;
readonly importDeclaration?: string | undefined;
} | undefined
generation: {
runtime: stringruntime: `Schema.ReadonlySet(?)`,
type Type: stringType: `globalThis.ReadonlySet<?>`
},
Annotations.Augment.expected?: string | undefinedHuman-readable description of what a value is expected to satisfy.
Details
For filter and refinement failures, the default formatter uses
message first, then expected, and finally falls back to <filter>.
Use this to name a failed filter in the default message:
Expected <expected>, got <actual>.
expected: "ReadonlySet",
Annotations.Declaration<ReadonlySet<Value["Type"]>, readonly [Value]>.toCodec?: ((typeParameters: readonly [Codec<Value["Encoded"], Value["Encoded"], never, never>]) => SchemaAST.Link) | undefinedtoCodec: ([value: Codec<
Value["Encoded"],
Value["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<Value['Encoded'], any>) => Codec<Value['Encoded'], Value['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<Value['Encoded']>) => Codec<Value['Encoded'], Value['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<Value['Encoded']>, ...checks: Array<SchemaAST.Check<Value['Encoded']>>) => Codec<Value['Encoded'], Value['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<Value['Encoded'], Value['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => Value['Encoded'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<Value['Encoded']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<Value['Encoded'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
value]) =>
function link<T>(): <
To extends Constraint
>(
encodeTo: To,
transformation: {
readonly decode: SchemaGetter.Getter<
T,
NoInfer<To["Type"]>
>
readonly encode: SchemaGetter.Getter<
NoInfer<To["Type"]>,
T
>
}
) => SchemaAST.Link
Constructs an SchemaAST.Link that describes how a value of type T encodes to and decodes from a To schema.
Used when building low-level AST transformations that bridge two schema types.
link<module globalThisglobalThis.interface Set<T>Set<function (type parameter) Value in ReadonlySet<Value extends Constraint>(value: Value): $ReadonlySet<Value>Value["Encoded"]>>()(
const ArraySchema: ArrayLambda
<Codec<Value["Encoded"], Value["Encoded"], never, never>>(self: Codec<Value["Encoded"], Value["Encoded"], never, never>) => $Array<Codec<Value["Encoded"], Value["Encoded"], never, never>>
ArraySchema(value: Codec<
Value["Encoded"],
Value["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<Value['Encoded'], any>) => Codec<Value['Encoded'], Value['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<Value['Encoded']>) => Codec<Value['Encoded'], Value['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<Value['Encoded']>, ...checks: Array<SchemaAST.Check<Value['Encoded']>>) => Codec<Value['Encoded'], Value['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<Value['Encoded'], Value['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => Value['Encoded'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<Value['Encoded']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<Value['Encoded'], SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
value),
import SchemaTransformationSchemaTransformation.function transform<T, E>(options: {
readonly decode: (input: E) => T
readonly encode: (input: T) => E
}): Transformation<T, E>
Creates a Transformation from pure (sync, infallible) decode and encode
functions.
When to use
Use when you need an infallible schema transformation that does not require
Effect services.
Details
- Each function receives the input and returns the output directly.
- Skips
None inputs (missing keys) — functions are only called on present values.
- Does not allocate Effects internally; uses optimized sync path.
Example (Converting between cents and dollars)
import { Schema, SchemaTransformation } from "effect"
const CentsFromDollars = Schema.Number.pipe(
Schema.decodeTo(
Schema.Number,
SchemaTransformation.transform({
decode: (dollars) => dollars * 100,
encode: (cents) => cents / 100
})
)
)
transform({
decode: (
input: NoInfer<readonly Value["Encoded"][]>
) => Set<Value["Encoded"]>
decode: (e: NoInfer<readonly Value["Encoded"][]>e) => new module globalThisglobalThis.var Set: SetConstructor
new <Value["Encoded"]>(iterable?: Iterable<Value["Encoded"]> | null | undefined) => Set<Value["Encoded"]> (+1 overload)
Set(e: readonly Value["Encoded"][]e),
encode: (
input: Set<Value["Encoded"]>
) => NoInfer<readonly Value["Encoded"][]>
encode: (set: Set<Value["Encoded"]>set) => [...set: Set<Value["Encoded"]>set.Set<Value["Encoded"]>.values(): SetIterator<Value["Encoded"]>Returns an iterable of values in the set.
values()]
})
),
Annotations.Declaration<ReadonlySet<Value["Type"]>, readonly [Value]>.toArbitrary?: Annotations.ToArbitrary.Declaration<ReadonlySet<Value["Type"]>, readonly [Value]> | undefinedtoArbitrary: ([value: Annotations.ToArbitrary.TypeParameter<
Value["Type"]
>
(parameter) value: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
value]) => (fc: typeof FastCheckfc, ctx: Annotations.ToArbitrary.Context(parameter) ctx: {
constraint: ToArbitrary.GenerationConstraint | undefined;
recursion: ToArbitrary.Recursion | undefined;
}
ctx) =>
function collectionArbitrary<unknown, Set<unknown>>(fc: typeof FastCheck, ctx: Annotations.ToArbitrary.Context, item: FastCheck.Arbitrary<unknown>, terminalItem: FastCheck.Arbitrary<unknown> | undefined, fromIterable: (items: unknown[]) => Set<unknown>, comparator?: ((a: unknown, b: unknown) => boolean) | undefined): {
arbitrary: any;
terminal: any;
}
collectionArbitrary(fc: typeof FastCheckfc, ctx: Annotations.ToArbitrary.Context(parameter) ctx: {
constraint: ToArbitrary.GenerationConstraint | undefined;
recursion: ToArbitrary.Recursion | undefined;
}
ctx, value: Annotations.ToArbitrary.TypeParameter<
Value["Type"]
>
(parameter) value: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
value.Annotations.ToArbitrary.TypeParameter<T>.arbitrary: FastCheck.Arbitrary<T>arbitrary, value: Annotations.ToArbitrary.TypeParameter<
Value["Type"]
>
(parameter) value: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
value.Annotations.ToArbitrary.TypeParameter<T>.terminal: anyterminal, (as: unknown[]as) => new module globalThisglobalThis.var Set: SetConstructor
new <unknown>(iterable?: Iterable<unknown> | null | undefined) => Set<unknown> (+1 overload)
Set(as: unknown[]as), import EqualEqual.equals),
Annotations.Declaration<ReadonlySet<Value["Type"]>, readonly [Value]>.toEquivalence?: Annotations.ToEquivalence.Declaration<ReadonlySet<Value["Type"]>, readonly [Value]> | undefinedtoEquivalence: ([value: Equivalence.Equivalence<Value["Type"]>value]) => import EqualEqual.makeCompareSet(value: Equivalence.Equivalence<Value["Type"]>value),
Annotations.Declaration<ReadonlySet<Value["Type"]>, readonly [Value]>.toFormatter?: Annotations.ToFormatter.Declaration<ReadonlySet<Value["Type"]>, readonly [Value]> | undefinedtoFormatter: ([value: Formatter<Value["Type"], string>value]) => (t: anyt) => {
const const size: anysize = t: anyt.size
if (const size: anysize === 0) {
return "ReadonlySet(0) {}"
}
const const values: string[]values = module globalThisglobalThis.var Array: ArrayConstructorArray.ArrayConstructor.from<unknown>(iterable: Iterable<unknown> | ArrayLike<unknown>): unknown[] (+3 overloads)Creates an array from an iterable object.
from(t: anyt.values()).Array<unknown>.sort(compareFn?: ((a: unknown, b: unknown) => number) | undefined): unknown[]Sorts an array in place.
This method mutates the array and returns a reference to the same array.
sort().Array<unknown>.map<string>(callbackfn: (value: unknown, index: number, array: unknown[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((v: unknownv) => `${value: Formatter<Value["Type"], string>value(v: unknownv)}`)
return `ReadonlySet(${const size: anysize}) { ${const values: string[]values.Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")} }`
}
}
)
return const make: <S extends Constraint>(
ast: S["ast"],
options?: object
) => S
Creates a schema from an AST (Abstract Syntax Tree) node.
Details
This is the fundamental constructor for all schemas in the Effect Schema
library. It takes an AST node and wraps it in a fully-typed schema that
preserves all type information and provides the complete schema API.
The make function is used internally to create all primitive schemas like
String, Number, Boolean, etc., as well as more complex schemas. It's
the bridge between the untyped AST representation and the strongly-typed
schema.
make(const schema: declareConstructor<
ReadonlySet<Value["Type"]>,
ReadonlySet<Value["Encoded"]>,
readonly [Value],
ReadonlySetIso<Value>
>
const schema: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<ReadonlySet<Value['Type']>, readonly [Value]>) => declareConstructor<ReadonlySet<Value['Type']>, ReadonlySet<Value['Encoded']>, readonly [Value], ReadonlySetIso<Value>>;
annotateKey: (annotations: Annotations.Key<ReadonlySet<Value['Type']>>) => declareConstructor<ReadonlySet<Value['Type']>, ReadonlySet<Value['Encoded']>, readonly [Value], ReadonlySetIso<Value>>;
check: (checks_0: SchemaAST.Check<ReadonlySet<Value['Type']>>, ...checks: Array<SchemaAST.Check<ReadonlySet<Value['Type']>>>) => declareConstructor<ReadonlySet<Value['Type']>, ReadonlySet<Value['Encoded']>, readonly [Value], ReadonlySetIso<Value>>;
rebuild: (ast: SchemaAST.Declaration) => declareConstructor<ReadonlySet<Value['Type']>, ReadonlySet<Value['Encoded']>, readonly [Value], ReadonlySetIso<Value>>;
make: (input: ReadonlySet<Value['Type']>, options?: MakeOptions) => ReadonlySet<Value['Type']>;
makeOption: (input: ReadonlySet<Value['Type']>, options?: MakeOptions) => Option_.Option<ReadonlySet<Value['Type']>>;
makeEffect: (input: ReadonlySet<Value['Type']>, options?: MakeOptions) => Effect.Effect<ReadonlySet<Value['Type']>, SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
schema.Bottom<ReadonlySet<Value["Type"]>, ReadonlySet<Value["Encoded"]>, Value["DecodingServices"], Value["EncodingServices"], ... 10 more ..., "required">["ast"]: SchemaAST.Declaration(property) Bottom<ReadonlySet<Value["Type"]>, ReadonlySet<Value["Encoded"]>, Value["DecodingServices"], Value["EncodingServices"], ... 10 more ..., "required">["ast"]: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, { value: Value extends Constraintvalue })
}