ObjectsAST node for object-like schemas, including structs and records.
When to use
Use when constructing or inspecting AST nodes for structs or records rather than array-like schemas.
Details
propertySignatures— named properties with their types (struct fields).indexSignatures— index signature entries (record patterns), each with aparameterAST for matching keys and atypeAST for values.
An Objects node with no properties and no index signatures performs only a
non-nullish check: it accepts any value except null and undefined,
including primitive values.
Gotchas
Duplicate property names throw at construction time.
Example (Inspecting a struct AST)
import { Schema, SchemaAST } from "effect"
const schema = Schema.Struct({ name: Schema.String })
const ast = schema.ast
if (SchemaAST.isObjects(ast)) {
for (const ps of ast.propertySignatures) {
console.log(ps.name, ps.type._tag)
}
// "name" "String"
}export class class Objectsclass Objects {
_tag: 'Objects';
propertySignatures: ReadonlyArray<PropertySignature>;
indexSignatures: ReadonlyArray<IndexSignature>;
encodingChecks: Checks | undefined;
getParser: (recur: (ast: AST) => SchemaParser.Parser) => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, recurParameter: (ast: AST) => AST, flipMerge: boolean, checks: Checks | undefined, encodingChecks: Checks | undefined) => Objects;
flip: (recur: (ast: AST) => AST) => AST;
recur: (recur: (ast: AST) => AST, recurParameter?: (ast: AST) => AST) => AST;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
AST node for object-like schemas, including structs and records.
When to use
Use when constructing or inspecting AST nodes for structs or records rather
than array-like schemas.
Details
propertySignatures — named properties with their types (struct fields).
indexSignatures — index signature entries (record patterns), each with
a parameter AST for matching keys and a type AST for values.
An Objects node with no properties and no index signatures performs only a
non-nullish check: it accepts any value except null and undefined,
including primitive values.
Gotchas
Duplicate property names throw at construction time.
Example (Inspecting a struct AST)
import { Schema, SchemaAST } from "effect"
const schema = Schema.Struct({ name: Schema.String })
const ast = schema.ast
if (SchemaAST.isObjects(ast)) {
for (const ps of ast.propertySignatures) {
console.log(ps.name, ps.type._tag)
}
// "name" "String"
}
Objects extends class BaseRepresents the abstract base class for all
AST
node variants.
Details
Every AST node extends Base and inherits these fields:
annotations — user-supplied metadata (identifier, title, description,
arbitrary keys).
checks — optional
Checks
for post-type-match validation.
encoding — optional
Encoding
chain for type ↔ wire
transformations.
context — optional
Context
for per-property metadata.
Subclasses add a _tag discriminant and variant-specific data.
Base {
readonly Objects._tag: "Objects"_tag = "Objects"
readonly Objects.propertySignatures: ReadonlyArray<PropertySignature>propertySignatures: interface ReadonlyArray<T>ReadonlyArray<class PropertySignatureclass PropertySignature {
name: PropertyKey;
type: AST;
}
PropertySignature>
readonly Objects.indexSignatures: ReadonlyArray<IndexSignature>indexSignatures: interface ReadonlyArray<T>ReadonlyArray<class IndexSignatureclass IndexSignature {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
Represents an index signature entry within an
Objects
node.
When to use
Use when constructing or inspecting object AST entries for record-like keys
and values.
Details
parameter — the key type AST (e.g.
String
for string keys,
TemplateLiteral
for patterned keys).
type — the value type SchemaAST.
merge — optional
KeyValueCombiner
for handling duplicate keys.
Gotchas
Using Schema.optionalKey on the value type is not allowed for index
signatures (throws at construction); use Schema.optional instead.
IndexSignature>
readonly Objects.encodingChecks: Checks | undefinedencodingChecks: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks | undefined
constructor(
propertySignatures: ReadonlyArray<PropertySignature>propertySignatures: interface ReadonlyArray<T>ReadonlyArray<class PropertySignatureclass PropertySignature {
name: PropertyKey;
type: AST;
}
PropertySignature>,
indexSignatures: ReadonlyArray<IndexSignature>indexSignatures: interface ReadonlyArray<T>ReadonlyArray<class IndexSignatureclass IndexSignature {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
Represents an index signature entry within an
Objects
node.
When to use
Use when constructing or inspecting object AST entries for record-like keys
and values.
Details
parameter — the key type AST (e.g.
String
for string keys,
TemplateLiteral
for patterned keys).
type — the value type SchemaAST.
merge — optional
KeyValueCombiner
for handling duplicate keys.
Gotchas
Using Schema.optionalKey on the value type is not allowed for index
signatures (throws at construction); use Schema.optional instead.
IndexSignature>,
annotations: anyannotations?: import SchemaSchema.declareAnnotations.type Schema.Annotations.Annotations = /*unresolved*/ anyAnnotations,
checks: Checkschecks?: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks,
encoding: Encodingencoding?: type Encoding = readonly [Link, ...Link[]]A non-empty chain of
Link
values representing the transformation
steps between a schema's decoded (type) form and its encoded (wire) form.
Details
Stored on
Base.encoding
. When undefined, the node has no
encoding transformation (type and encoded forms are identical).
Encoding,
context: Contextcontext?: class Contextclass Context {
isOptional: boolean;
isMutable: boolean;
defaultValue: Encoding | undefined;
annotations: Schema.Annotations.Key<unknown> | undefined;
}
Represents per-property metadata attached to AST nodes via
Base.context
.
Details
Tracks whether a property key is optional, mutable, has a constructor
default, or carries key-level annotations. Typically set by helpers like
optionalKey
and Schema.mutableKey.
isOptional — the property key may be absent from the input.
isMutable — the property is readonly when false.
defaultValue — an
Encoding
applied during construction to
supply missing values.
annotations — key-level annotations (e.g. description of the key
itself).
Context,
encodingChecks: ChecksencodingChecks?: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks
) {
super(annotations: anyannotations, checks: Checkschecks, encoding: Encodingencoding, context: Contextcontext)
this.Objects.propertySignatures: ReadonlyArray<PropertySignature>propertySignatures = propertySignatures: ReadonlyArray<PropertySignature>propertySignatures
this.Objects.indexSignatures: ReadonlyArray<IndexSignature>indexSignatures = indexSignatures: ReadonlyArray<IndexSignature>indexSignatures
this.Objects.encodingChecks: Checks | undefinedencodingChecks = encodingChecks: ChecksencodingChecks
// Duplicate property signatures
const const duplicates: PropertyKey[]duplicates = propertySignatures: ReadonlyArray<PropertySignature>propertySignatures.ReadonlyArray<PropertySignature>.map<PropertyKey>(callbackfn: (value: PropertySignature, index: number, array: readonly PropertySignature[]) => PropertyKey, thisArg?: any): PropertyKey[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((ps: PropertySignature(parameter) ps: {
name: PropertyKey;
type: AST;
}
ps) => ps: PropertySignature(parameter) ps: {
name: PropertyKey;
type: AST;
}
ps.PropertySignature.name: PropertyKeyname).Array<PropertyKey>.filter(predicate: (value: PropertyKey, index: number, array: PropertyKey[]) => unknown, thisArg?: any): PropertyKey[] (+1 overload)Returns the elements of an array that meet the condition specified in a callback function.
filter((name: PropertyKeyname, i: numberi, arr: PropertyKey[]arr) => arr: PropertyKey[]arr.Array<PropertyKey>.indexOf(searchElement: PropertyKey, fromIndex?: number): numberReturns the index of the first occurrence of a value in an array, or -1 if it is not present.
indexOf(name: PropertyKeyname) !== i: numberi)
if (const duplicates: PropertyKey[]duplicates.Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length > 0) {
throw new var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+1 overload)
Error(`Duplicate identifiers: ${var JSON: JSONAn intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
JSON.JSON.stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string (+1 overload)Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
stringify(const duplicates: PropertyKey[]duplicates)}. ts(2300)`)
}
}
/** @internal */
Objects.getParser(recur: (ast: AST) => SchemaParser.Parser): SchemaParser.ParsergetParser(recur: (ast: AST) => SchemaParser.Parserrecur: (ast: ASTast: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) => import SchemaParserSchemaParser.Parser): import SchemaParserSchemaParser.Parser {
// oxlint-disable-next-line @typescript-eslint/no-this-alias
const const ast: thisast = this
const const expectedKeys: PropertyKey[]expectedKeys: interface Array<T>Array<type PropertyKey =
| string
| number
| symbol
PropertyKey> = []
const const expectedKeysSet: Set<PropertyKey>expectedKeysSet = new var Set: SetConstructor
new <PropertyKey>(iterable?: Iterable<PropertyKey> | null | undefined) => Set<PropertyKey> (+1 overload)
Set<type PropertyKey =
| string
| number
| symbol
PropertyKey>()
const const properties: Array<{
readonly ps: PropertySignature | IndexSignature
readonly parser: SchemaParser.Parser
readonly name: PropertyKey
readonly type: AST
}>
properties: interface Array<T>Array<{
readonly ps: PropertySignature | IndexSignatureps: class PropertySignatureclass PropertySignature {
name: PropertyKey;
type: AST;
}
PropertySignature | class IndexSignatureclass IndexSignature {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
Represents an index signature entry within an
Objects
node.
When to use
Use when constructing or inspecting object AST entries for record-like keys
and values.
Details
parameter — the key type AST (e.g.
String
for string keys,
TemplateLiteral
for patterned keys).
type — the value type SchemaAST.
merge — optional
KeyValueCombiner
for handling duplicate keys.
Gotchas
Using Schema.optionalKey on the value type is not allowed for index
signatures (throws at construction); use Schema.optional instead.
IndexSignature
readonly parser: SchemaParser.Parserparser: import SchemaParserSchemaParser.Parser
readonly name: PropertyKeyname: type PropertyKey =
| string
| number
| symbol
PropertyKey
readonly type: ASTtype: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST
}> = []
for (const const ps: PropertySignatureconst ps: {
name: PropertyKey;
type: AST;
}
ps of const ast: thisast.Objects.propertySignatures: ReadonlyArray<PropertySignature>propertySignatures) {
const expectedKeys: PropertyKey[]expectedKeys.Array<PropertyKey>.push(...items: PropertyKey[]): numberAppends new elements to the end of an array, and returns the new length of the array.
push(const ps: PropertySignatureconst ps: {
name: PropertyKey;
type: AST;
}
ps.PropertySignature.name: PropertyKeyname)
const expectedKeysSet: Set<PropertyKey>expectedKeysSet.Set<PropertyKey>.add(value: PropertyKey): Set<PropertyKey>Appends a new element with a specified value to the end of the Set.
add(const ps: PropertySignatureconst ps: {
name: PropertyKey;
type: AST;
}
ps.PropertySignature.name: PropertyKeyname)
const properties: Array<{
readonly ps: PropertySignature | IndexSignature
readonly parser: SchemaParser.Parser
readonly name: PropertyKey
readonly type: AST
}>
properties.function Array(...items: Array<{ readonly ps: PropertySignature | IndexSignature; readonly parser: SchemaParser.Parser; readonly name: PropertyKey; readonly type: AST }>): numberAppends new elements to the end of an array, and returns the new length of the array.
push({
ps: PropertySignature(property) ps: {
name: PropertyKey;
type: AST;
}
ps,
parser: SchemaParser.Parserparser: recur: (ast: AST) => SchemaParser.Parserrecur(const ps: PropertySignatureconst ps: {
name: PropertyKey;
type: AST;
}
ps.PropertySignature.type: ASTtype),
name: PropertyKeyname: const ps: PropertySignatureconst ps: {
name: PropertyKey;
type: AST;
}
ps.PropertySignature.name: PropertyKeyname,
type: ASTtype: const ps: PropertySignatureconst ps: {
name: PropertyKey;
type: AST;
}
ps.PropertySignature.type: ASTtype
})
}
const const indexCount: numberindexCount = const ast: thisast.Objects.indexSignatures: ReadonlyArray<IndexSignature>indexSignatures.ReadonlyArray<T>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length
// ---------------------------------------------
// handle empty struct
// ---------------------------------------------
if (const ast: thisast.Objects.propertySignatures: ReadonlyArray<PropertySignature>propertySignatures.ReadonlyArray<T>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length === 0 && const ast: thisast.Objects.indexSignatures: ReadonlyArray<IndexSignature>indexSignatures.ReadonlyArray<T>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length === 0) {
return function fromRefinement<T>(
ast: AST,
refinement: (input: unknown) => input is T
): SchemaParser.Parser
fromRefinement(const ast: thisast, import PredicatePredicate.isNotNullish)
}
const const parseIndexes:
| ((
initialState: {
readonly oinput: Option.Option<unknown>
readonly input: Record<
PropertyKey,
unknown
>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues:
| Array<SchemaIssue.Issue>
| undefined
},
items: ReadonlyArray<
[key: PropertyKey, is: IndexSignature]
>,
options?: IterateEagerOptions
) =>
| Effect.Effect<
void,
SchemaIssue.Issue,
any
>
| undefined)
| undefined
parseIndexes = const indexCount: numberindexCount > 0 ?
iterateEager<S, A>(): <X, E, R, E2>(options: { readonly onItem: (state: S, item: A, index: number) => Effect.Effect<X, E, R>; readonly step: (state: NoInfer<S>, item: A, exit: Exit.Exit<X, E>, index: number) => Exit.Exit<void, E2> | void }) => (initialState: S, items: ReadonlyArray<A>, options?: IterateEagerOptions) => Effect.Effect<void, E | E2, R> | undefinediterateEager<{
readonly oinput: Option.Option<unknown>oinput: import OptionOption.type Option.Option = /*unresolved*/ anyOption<unknown>
readonly input: Record<PropertyKey, unknown>input: type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<type PropertyKey =
| string
| number
| symbol
PropertyKey, unknown>
readonly options: ParseOptions(property) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options: ParseOptions
readonly out: Record<PropertyKey, unknown>out: type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<type PropertyKey =
| string
| number
| symbol
PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefinedissues: interface Array<T>Array<import SchemaIssueSchemaIssue.type Issue =
| SchemaIssue.Leaf
| SchemaIssue.Filter
| SchemaIssue.Encoding
| SchemaIssue.Pointer
| SchemaIssue.Composite
| SchemaIssue.AnyOf
The root discriminated union of all validation error nodes.
When to use
Use when typing the error channel in Effect<A, Issue, R> results from
schema parsing, or when writing custom formatters or issue-tree walkers.
Details
Every node has a _tag field for pattern-matching. The union includes both
terminal
Leaf
types and composite types that wrap inner issues:
Filter
,
Encoding
,
Pointer
,
Composite
,
AnyOf
. All Issue instances have a toString() that delegates to
the default formatter, so String(issue) produces a human-readable message.
Issue> | undefined
}, [PropertyKeykey: type PropertyKey =
| string
| number
| symbol
PropertyKey, IndexSignatureRepresents an index signature entry within an
Objects
node.
When to use
Use when constructing or inspecting object AST entries for record-like keys
and values.
Details
parameter — the key type AST (e.g.
String
for string keys,
TemplateLiteral
for patterned keys).
type — the value type SchemaAST.
merge — optional
KeyValueCombiner
for handling duplicate keys.
Gotchas
Using Schema.optionalKey on the value type is not allowed for index
signatures (throws at construction); use Schema.optional instead.
is: class IndexSignatureclass IndexSignature {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
Represents an index signature entry within an
Objects
node.
When to use
Use when constructing or inspecting object AST entries for record-like keys
and values.
Details
parameter — the key type AST (e.g.
String
for string keys,
TemplateLiteral
for patterned keys).
type — the value type SchemaAST.
merge — optional
KeyValueCombiner
for handling duplicate keys.
Gotchas
Using Schema.optionalKey on the value type is not allowed for index
signatures (throws at construction); use Schema.optional instead.
IndexSignature]>()({
onItem: (
s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
},
args_1: [key: PropertyKey, is: IndexSignature]
) => Effect.Effect<void, SchemaIssue.Issue, any>
onItem: import EffectEffect.fnUntracedEager(function*(
s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
(parameter) s: {
oinput: Option.Option<unknown>;
input: Record<PropertyKey, unknown>;
options: ParseOptions;
out: Record<PropertyKey, unknown>;
issues: Array<SchemaIssue.Issue> | undefined;
}
s,
[key: anykey, is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is]
) {
const const parserKey: SchemaParser.ParserparserKey = recur: (ast: AST) => SchemaParser.Parserrecur(const parameterFromPropertyKey: anyparameterFromPropertyKey(is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.parameter))
const const effKey: Effect.Effect<
Option.Option<unknown>,
SchemaIssue.Issue,
any
>
const effKey: {
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; <…;
toString: () => string;
toJSON: () => unknown;
}
effKey = const parserKey: SchemaParser.Parser
;(
input: Option.Option<unknown>,
options: ParseOptions
) =>
Effect.Effect<
Option.Option<unknown>,
SchemaIssue.Issue,
any
>
parserKey(import OptionOption.some(key: anykey), s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
(parameter) s: {
oinput: Option.Option<unknown>;
input: Record<PropertyKey, unknown>;
options: ParseOptions;
out: Record<PropertyKey, unknown>;
issues: Array<SchemaIssue.Issue> | undefined;
}
s.options)
const const exitKey: Exit.Exit<
Option.Option<PropertyKey>,
SchemaIssue.Issue
>
exitKey = (effectIsExit<A, E, R>(effect: Effect.Effect<A, E, R>): effect is Exit.Exit<A, E>effectIsExit(const effKey: Effect.Effect<
Option.Option<unknown>,
SchemaIssue.Issue,
any
>
const effKey: {
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; <…;
toString: () => string;
toJSON: () => unknown;
}
effKey) ? const effKey: Exit.Exit<
Option.Option<unknown>,
SchemaIssue.Issue
>
effKey : yield* import EffectEffect.exit(const effKey: Effect.Effect<
Option.Option<unknown>,
SchemaIssue.Issue,
any
>
const effKey: {
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; <…;
toString: () => string;
toJSON: () => unknown;
}
effKey)) as import ExitExit.type Exit.Exit = /*unresolved*/ anyExit<
import OptionOption.type Option.Option = /*unresolved*/ anyOption<type PropertyKey =
| string
| number
| symbol
PropertyKey>,
import SchemaIssueSchemaIssue.type Issue =
| SchemaIssue.Leaf
| SchemaIssue.Filter
| SchemaIssue.Encoding
| SchemaIssue.Pointer
| SchemaIssue.Composite
| SchemaIssue.AnyOf
The root discriminated union of all validation error nodes.
When to use
Use when typing the error channel in Effect<A, Issue, R> results from
schema parsing, or when writing custom formatters or issue-tree walkers.
Details
Every node has a _tag field for pattern-matching. The union includes both
terminal
Leaf
types and composite types that wrap inner issues:
Filter
,
Encoding
,
Pointer
,
Composite
,
AnyOf
. All Issue instances have a toString() that delegates to
the default formatter, so String(issue) produces a human-readable message.
Issue
>
if (const exitKey: Exit.Exit<
Option.Option<PropertyKey>,
SchemaIssue.Issue
>
exitKey._tag === "Failure") {
const const eff: anyeff = const wrapPropertyKeyIssue: (
s: {
readonly oinput: Option.Option<unknown>
readonly options: ParseOptions
issues: Array<SchemaIssue.Issue> | undefined
},
ast: AST,
key: PropertyKey,
exit: Exit.Failure<any, SchemaIssue.Issue>
) =>
| Exit.Failure<any, SchemaIssue.Issue>
| Exit.Success<never, SchemaIssue.Composite>
| undefined
wrapPropertyKeyIssue(s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
(parameter) s: {
oinput: Option.Option<unknown>;
input: Record<PropertyKey, unknown>;
options: ParseOptions;
out: Record<PropertyKey, unknown>;
issues: Array<SchemaIssue.Issue> | undefined;
}
s, const ast: thisast, key: anykey, const exitKey: Exit.Failure<
Option.Option<PropertyKey>,
SchemaIssue.Issue
>
const exitKey: {
_tag: "Failure";
cause: Cause.Cause<E>;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
exitKey)
if (const eff: anyeff) yield* const eff: anyeff
return
}
const const value: Option.Option<unknown>value: import OptionOption.type Option.Option = /*unresolved*/ anyOption<unknown> = import OptionOption.some(s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
(parameter) s: {
oinput: Option.Option<unknown>;
input: Record<PropertyKey, unknown>;
options: ParseOptions;
out: Record<PropertyKey, unknown>;
issues: Array<SchemaIssue.Issue> | undefined;
}
s.input[key: anykey])
const const parserValue: SchemaParser.ParserparserValue = recur: (ast: AST) => SchemaParser.Parserrecur(is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.type)
const const effValue: Effect.Effect<
Option.Option<unknown>,
SchemaIssue.Issue,
any
>
const effValue: {
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; <…;
toString: () => string;
toJSON: () => unknown;
}
effValue = const parserValue: SchemaParser.Parser
;(
input: Option.Option<unknown>,
options: ParseOptions
) =>
Effect.Effect<
Option.Option<unknown>,
SchemaIssue.Issue,
any
>
parserValue(const value: Option.Option<unknown>value, s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
(parameter) s: {
oinput: Option.Option<unknown>;
input: Record<PropertyKey, unknown>;
options: ParseOptions;
out: Record<PropertyKey, unknown>;
issues: Array<SchemaIssue.Issue> | undefined;
}
s.options)
const const exitValue: Exit.Exit<
Option.Option<unknown>,
SchemaIssue.Issue
>
exitValue = effectIsExit<A, E, R>(effect: Effect.Effect<A, E, R>): effect is Exit.Exit<A, E>effectIsExit(const effValue: Effect.Effect<
Option.Option<unknown>,
SchemaIssue.Issue,
any
>
const effValue: {
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; <…;
toString: () => string;
toJSON: () => unknown;
}
effValue) ? const effValue: Exit.Exit<
Option.Option<unknown>,
SchemaIssue.Issue
>
effValue : yield* import EffectEffect.exit(const effValue: Effect.Effect<
Option.Option<unknown>,
SchemaIssue.Issue,
any
>
const effValue: {
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; <…;
toString: () => string;
toJSON: () => unknown;
}
effValue)
if (const exitValue: Exit.Exit<
Option.Option<unknown>,
SchemaIssue.Issue
>
exitValue._tag === "Failure") {
const const eff: anyeff = const wrapPropertyKeyIssue: (
s: {
readonly oinput: Option.Option<unknown>
readonly options: ParseOptions
issues: Array<SchemaIssue.Issue> | undefined
},
ast: AST,
key: PropertyKey,
exit: Exit.Failure<any, SchemaIssue.Issue>
) =>
| Exit.Failure<any, SchemaIssue.Issue>
| Exit.Success<never, SchemaIssue.Composite>
| undefined
wrapPropertyKeyIssue(s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
(parameter) s: {
oinput: Option.Option<unknown>;
input: Record<PropertyKey, unknown>;
options: ParseOptions;
out: Record<PropertyKey, unknown>;
issues: Array<SchemaIssue.Issue> | undefined;
}
s, const ast: thisast, key: anykey, const exitValue: Exit.Failure<
Option.Option<unknown>,
SchemaIssue.Issue
>
const exitValue: {
_tag: "Failure";
cause: Cause.Cause<E>;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
exitValue)
if (const eff: anyeff) yield* const eff: anyeff
return
} else if (const exitKey: Exit.Success<
Option.Option<PropertyKey>,
SchemaIssue.Issue
>
const exitKey: {
_tag: "Success";
value: A;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
exitKey.value._tag === "Some" && const exitValue: Exit.Success<
Option.Option<unknown>,
SchemaIssue.Issue
>
const exitValue: {
_tag: "Success";
value: A;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
exitValue.value._tag === "Some") {
const const k2: anyk2 = const exitKey: Exit.Success<
Option.Option<PropertyKey>,
SchemaIssue.Issue
>
const exitKey: {
_tag: "Success";
value: A;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
exitKey.value.value
if (const expectedKeysSet: Set<PropertyKey>expectedKeysSet.Set<PropertyKey>.has(value: PropertyKey): booleanhas(key: anykey) || const expectedKeysSet: Set<PropertyKey>expectedKeysSet.Set<PropertyKey>.has(value: PropertyKey): booleanhas(const k2: anyk2)) {
return
}
const const v2: anyv2 = const exitValue: Exit.Success<
Option.Option<unknown>,
SchemaIssue.Issue
>
const exitValue: {
_tag: "Success";
value: A;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
exitValue.value.value
if (is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.merge && is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.merge.decode && var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.hasOwn(o: object, v: PropertyKey): booleanDetermines whether an object has a property with the specified name.
hasOwn(s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
(parameter) s: {
oinput: Option.Option<unknown>;
input: Record<PropertyKey, unknown>;
options: ParseOptions;
out: Record<PropertyKey, unknown>;
issues: Array<SchemaIssue.Issue> | undefined;
}
s.out, const k2: anyk2)) {
const [const k: anyk, const v: anyv] = is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.merge.decode.combine([const k2: anyk2, s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
(parameter) s: {
oinput: Option.Option<unknown>;
input: Record<PropertyKey, unknown>;
options: ParseOptions;
out: Record<PropertyKey, unknown>;
issues: Array<SchemaIssue.Issue> | undefined;
}
s.out[const k2: anyk2]], [const k2: anyk2, const v2: anyv2])
import internalRecordinternalRecord.function set<any, any>(
self: Record<any, any>,
key: any,
value: any
): Record<any, any>
set(s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
(parameter) s: {
oinput: Option.Option<unknown>;
input: Record<PropertyKey, unknown>;
options: ParseOptions;
out: Record<PropertyKey, unknown>;
issues: Array<SchemaIssue.Issue> | undefined;
}
s.out, const k: anyk, const v: anyv)
} else {
import internalRecordinternalRecord.function set<any, any>(
self: Record<any, any>,
key: any,
value: any
): Record<any, any>
set(s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
(parameter) s: {
oinput: Option.Option<unknown>;
input: Record<PropertyKey, unknown>;
options: ParseOptions;
out: Record<PropertyKey, unknown>;
issues: Array<SchemaIssue.Issue> | undefined;
}
s.out, const k2: anyk2, const v2: anyv2)
}
}
}),
step: (
_s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
},
_: [key: PropertyKey, is: IndexSignature],
exit: Exit.Exit<void, SchemaIssue.Issue>
) =>
| Exit.Failure<void, SchemaIssue.Issue>
| undefined
step: (_s: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
}
_s, _: [key: PropertyKey, is: IndexSignature](parameter) _: {
0: PropertyKey;
1: IndexSignature;
length: 2;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => PropertyKey | IndexSignature | undefined;
push: (...items: Array<PropertyKey | IndexSignature>) => number;
concat: { (...items: Array<ConcatArray<PropertyKey | IndexSignature>>): Array<PropertyKey | IndexSignature>; (...items: Array<PropertyKey | IndexSignature | ConcatArray<PropertyKey | IndexSignature>>): Array<PropertyKey | IndexSignature> };
join: (separator?: string) => string;
reverse: () => Array<PropertyKey | IndexSignature>;
shift: () => PropertyKey | IndexSignature | undefined;
slice: (start?: number, end?: number) => Array<PropertyKey | IndexSignature>;
sort: (compareFn?: ((a: PropertyKey | IndexSignature, b: PropertyKey | IndexSignature) => number) | undefined) => [key: PropertyKey, is: IndexSignature];
splice: { (start: number, deleteCount?: number): Array<PropertyKey | IndexSignature>; (start: number, deleteCount: number, ...items: Array<PropertyKey | IndexSignature>): Array<PropertyKey | IndexSignature> };
unshift: (...items: Array<PropertyKey | IndexSignature>) => number;
indexOf: (searchElement: PropertyKey | IndexSignature, fromIndex?: number) => number;
lastIndexOf: (searchElement: PropertyKey | IndexSignature, fromIndex?: number) => number;
every: { (predicate: (value: PropertyKey | IndexSignature, index: number, array: Array<PropertyKey | IndexSignature>) => value is S, thisArg?: any): this is S[]; (predicate: (value: PropertyKey | IndexSignature, index: number, array: Array<Proper…;
some: (predicate: (value: PropertyKey | IndexSignature, index: number, array: Array<PropertyKey | IndexSignature>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: PropertyKey | IndexSignature, index: number, array: Array<PropertyKey | IndexSignature>) => void, thisArg?: any) => void;
map: (callbackfn: (value: PropertyKey | IndexSignature, index: number, array: Array<PropertyKey | IndexSignature>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: PropertyKey | IndexSignature, index: number, array: Array<PropertyKey | IndexSignature>) => value is S, thisArg?: any): Array<S>; (predicate: (value: PropertyKey | IndexSignature, index: number, array: Array<PropertyK…;
reduce: { (callbackfn: (previousValue: PropertyKey | IndexSignature, currentValue: PropertyKey | IndexSignature, currentIndex: number, array: Array<PropertyKey | IndexSignature>) => PropertyKey | IndexSignature): PropertyKey | IndexSignature; (cal…;
reduceRight: { (callbackfn: (previousValue: PropertyKey | IndexSignature, currentValue: PropertyKey | IndexSignature, currentIndex: number, array: Array<PropertyKey | IndexSignature>) => PropertyKey | IndexSignature): PropertyKey | IndexSignature; (cal…;
find: { (predicate: (value: PropertyKey | IndexSignature, index: number, obj: Array<PropertyKey | IndexSignature>) => value is S, thisArg?: any): S | undefined; (predicate: (value: PropertyKey | IndexSignature, index: number, obj: Array<Property…;
findIndex: (predicate: (value: PropertyKey | IndexSignature, index: number, obj: Array<PropertyKey | IndexSignature>) => unknown, thisArg?: any) => number;
fill: (value: PropertyKey | IndexSignature, start?: number, end?: number) => [key: PropertyKey, is: IndexSignature];
copyWithin: (target: number, start: number, end?: number) => [key: PropertyKey, is: IndexSignature];
entries: () => ArrayIterator<[number, PropertyKey | IndexSignature]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<PropertyKey | IndexSignature>;
includes: (searchElement: PropertyKey | IndexSignature, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: PropertyKey | IndexSignature, index: number, array: Array<PropertyKey | IndexSignature>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => PropertyKey | IndexSignature | undefined;
findLast: { (predicate: (value: PropertyKey | IndexSignature, index: number, array: Array<PropertyKey | IndexSignature>) => value is S, thisArg?: any): S | undefined; (predicate: (value: PropertyKey | IndexSignature, index: number, array: Array<Prop…;
findLastIndex: (predicate: (value: PropertyKey | IndexSignature, index: number, array: Array<PropertyKey | IndexSignature>) => unknown, thisArg?: any) => number;
toReversed: () => Array<PropertyKey | IndexSignature>;
toSorted: (compareFn?: ((a: PropertyKey | IndexSignature, b: PropertyKey | IndexSignature) => number) | undefined) => Array<PropertyKey | IndexSignature>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<PropertyKey | IndexSignature>): Array<PropertyKey | IndexSignature>; (start: number, deleteCount?: number): Array<PropertyKey | IndexSignature> };
with: (index: number, value: PropertyKey | IndexSignature) => Array<PropertyKey | IndexSignature>;
}
_, exit: Exit.Exit<void, SchemaIssue.Issue>exit: import ExitExit.type Exit.Exit = /*unresolved*/ anyExit<void, import SchemaIssueSchemaIssue.type Issue =
| SchemaIssue.Leaf
| SchemaIssue.Filter
| SchemaIssue.Encoding
| SchemaIssue.Pointer
| SchemaIssue.Composite
| SchemaIssue.AnyOf
The root discriminated union of all validation error nodes.
When to use
Use when typing the error channel in Effect<A, Issue, R> results from
schema parsing, or when writing custom formatters or issue-tree walkers.
Details
Every node has a _tag field for pattern-matching. The union includes both
terminal
Leaf
types and composite types that wrap inner issues:
Filter
,
Encoding
,
Pointer
,
Composite
,
AnyOf
. All Issue instances have a toString() that delegates to
the default formatter, so String(issue) produces a human-readable message.
Issue>) => exit: Exit.Exit<void, SchemaIssue.Issue>exit._tag === "Failure" ? exit: Exit.Exit<void, SchemaIssue.Issue>(parameter) exit: {
_tag: "Failure";
cause: Cause.Cause<E>;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
exit : var undefinedundefined
}) :
var undefinedundefined
return import EffectEffect.fnUntracedEager(function*(oinput: Option.Option<unknown>oinput, options: 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 (oinput: Option.Option<unknown>oinput._tag === "None") {
return oinput: Option.None<unknown>(parameter) oinput: {
_tag: "None";
_op: "None";
valueOrUndefined: undefined;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
oinput
}
const const input: Record<PropertyKey, unknown>input = oinput: Option.Some<unknown>(parameter) oinput: {
_tag: "Some";
_op: "Some";
value: A;
valueOrUndefined: A;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
oinput.value as type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<type PropertyKey =
| string
| number
| symbol
PropertyKey, unknown>
// If the input is not a record, return early with an error
if (!(typeof const input: Record<PropertyKey, unknown>input === "object" && const input: Record<PropertyKey, unknown>input !== null && !var Array: ArrayConstructorArray.ArrayConstructor.isArray(arg: any): arg is any[]isArray(const input: Record<PropertyKey, unknown>input))) {
return yield* import EffectEffect.fail(new import SchemaIssueSchemaIssue.constructor InvalidType(ast: AST, actual: Option.Option<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(const ast: thisast, oinput: Option.Some<unknown>(parameter) oinput: {
_tag: "Some";
_op: "Some";
value: A;
valueOrUndefined: A;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
oinput))
}
const const out: Record<PropertyKey, unknown>out: type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<type PropertyKey =
| string
| number
| symbol
PropertyKey, unknown> = {}
const const state: {
ast: this
oinput: any
input: Record<PropertyKey, unknown>
out: Record<PropertyKey, unknown>
issues:
| Arr.NonEmptyArray<SchemaIssue.Issue>
| undefined
options: any
}
state = {
ast: thisast,
oinput: Option.Some<unknown>(property) oinput: {
_tag: "Some";
_op: "Some";
value: A;
valueOrUndefined: A;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
oinput,
input: Record<PropertyKey, unknown>input,
out: Record<PropertyKey, unknown>out,
issues: anyissues: var undefinedundefined as import ArrArr.type Arr.NonEmptyArray = /*unresolved*/ anyNonEmptyArray<import SchemaIssueSchemaIssue.type Issue =
| SchemaIssue.Leaf
| SchemaIssue.Filter
| SchemaIssue.Encoding
| SchemaIssue.Pointer
| SchemaIssue.Composite
| SchemaIssue.AnyOf
The root discriminated union of all validation error nodes.
When to use
Use when typing the error channel in Effect<A, Issue, R> results from
schema parsing, or when writing custom formatters or issue-tree walkers.
Details
Every node has a _tag field for pattern-matching. The union includes both
terminal
Leaf
types and composite types that wrap inner issues:
Filter
,
Encoding
,
Pointer
,
Composite
,
AnyOf
. All Issue instances have a toString() that delegates to
the default formatter, so String(issue) produces a human-readable message.
Issue> | undefined,
options: ParseOptions(property) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options
}
const const errorsAllOption: booleanerrorsAllOption = options: ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options.errors === "all"
const const onExcessPropertyError: booleanonExcessPropertyError = options: ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options.onExcessProperty === "error"
const const onExcessPropertyPreserve: booleanonExcessPropertyPreserve = options: ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options.onExcessProperty === "preserve"
// ---------------------------------------------
// handle excess properties
// ---------------------------------------------
let let inputKeys: PropertyKey[] | undefinedinputKeys: interface Array<T>Array<type PropertyKey =
| string
| number
| symbol
PropertyKey> | undefined
if (const ast: thisast.Objects.indexSignatures: ReadonlyArray<IndexSignature>indexSignatures.ReadonlyArray<T>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length === 0 && (const onExcessPropertyError: booleanonExcessPropertyError || const onExcessPropertyPreserve: booleanonExcessPropertyPreserve)) {
let inputKeys: PropertyKey[] | undefinedinputKeys = Reflect.function Reflect.ownKeys(target: object): (string | symbol)[]Returns the string and symbol keys of the own properties of an object. The own properties of an object
are those that are defined directly on that object, and are not inherited from the object's prototype.
ownKeys(const input: Record<PropertyKey, unknown>input)
for (let let i: numberi = 0; let i: numberi < let inputKeys: PropertyKey[]inputKeys.Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length; let i: numberi++) {
const const key: PropertyKeykey = let inputKeys: PropertyKey[]inputKeys[let i: numberi]
if (!const expectedKeysSet: Set<PropertyKey>expectedKeysSet.Set<PropertyKey>.has(value: PropertyKey): booleanhas(const key: PropertyKeykey)) {
// key is unexpected
if (const onExcessPropertyError: booleanonExcessPropertyError) {
const const issue: SchemaIssue.Pointerconst issue: {
_tag: 'Pointer';
path: ReadonlyArray<PropertyKey>;
issue: Issue;
toString: (this: Issue) => string;
}
issue = 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([const key: PropertyKeykey], new import SchemaIssueSchemaIssue.constructor UnexpectedKey(ast: AST, actual: unknown): SchemaIssue.UnexpectedKeyRepresents a schema issue produced when an input object or tuple contains a key/index not
declared by the schema.
When to use
Use when you need to detect excess properties during strict struct/tuple
validation.
Details
actual is the raw value at the unexpected key (plain unknown).
ast is the schema that was being validated against.
annotations on ast may contain a custom messageUnexpectedKey.
UnexpectedKey(const ast: thisast, const input: Record<PropertyKey, unknown>input[const key: PropertyKeykey]))
if (const errorsAllOption: booleanerrorsAllOption) {
if (const state: {
ast: this
oinput: any
input: Record<PropertyKey, unknown>
out: Record<PropertyKey, unknown>
issues:
| Arr.NonEmptyArray<SchemaIssue.Issue>
| undefined
options: any
}
state.issues: anyissues) {
const state: {
ast: this
oinput: any
input: Record<PropertyKey, unknown>
out: Record<PropertyKey, unknown>
issues:
| Arr.NonEmptyArray<SchemaIssue.Issue>
| undefined
options: any
}
state.issues: any(property) issues: {
0: SchemaIssue.Issue;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => SchemaIssue.Issue | undefined;
push: (...items: Array<SchemaIssue.Issue>) => number;
concat: { (...items: Array<ConcatArray<SchemaIssue.Issue>>): Array<SchemaIssue.Issue>; (...items: Array<SchemaIssue.Issue | ConcatArray<SchemaIssue.Issue>>): Array<SchemaIssue.Issue> };
join: (separator?: string) => string;
reverse: () => Array<SchemaIssue.Issue>;
shift: () => SchemaIssue.Issue | undefined;
slice: (start?: number, end?: number) => Array<SchemaIssue.Issue>;
sort: (compareFn?: ((a: SchemaIssue.Issue, b: SchemaIssue.Issue) => number) | undefined) => [SchemaIssue.Issue, ...SchemaIssue.Issue[]];
splice: { (start: number, deleteCount?: number): Array<SchemaIssue.Issue>; (start: number, deleteCount: number, ...items: Array<SchemaIssue.Issue>): Array<SchemaIssue.Issue> };
unshift: (...items: Array<SchemaIssue.Issue>) => number;
indexOf: (searchElement: SchemaIssue.Issue, fromIndex?: number) => number;
lastIndexOf: (searchElement: SchemaIssue.Issue, fromIndex?: number) => number;
every: { (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => value is S, thisArg?: any): this is S[]; (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => unknown, thisArg…;
some: (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => void, thisArg?: any) => void;
map: (callbackfn: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => value is S, thisArg?: any): Array<S>; (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => unknown, thisArg?: …;
reduce: { (callbackfn: (previousValue: SchemaIssue.Issue, currentValue: SchemaIssue.Issue, currentIndex: number, array: Array<SchemaIssue.Issue>) => SchemaIssue.Issue): SchemaIssue.Issue; (callbackfn: (previousValue: SchemaIssue.Issue, currentValu…;
reduceRight: { (callbackfn: (previousValue: SchemaIssue.Issue, currentValue: SchemaIssue.Issue, currentIndex: number, array: Array<SchemaIssue.Issue>) => SchemaIssue.Issue): SchemaIssue.Issue; (callbackfn: (previousValue: SchemaIssue.Issue, currentValu…;
find: { (predicate: (value: SchemaIssue.Issue, index: number, obj: Array<SchemaIssue.Issue>) => value is S, thisArg?: any): S | undefined; (predicate: (value: SchemaIssue.Issue, index: number, obj: Array<SchemaIssue.Issue>) => unknown, thisArg?:…;
findIndex: (predicate: (value: SchemaIssue.Issue, index: number, obj: Array<SchemaIssue.Issue>) => unknown, thisArg?: any) => number;
fill: (value: SchemaIssue.Issue, start?: number, end?: number) => [SchemaIssue.Issue, ...SchemaIssue.Issue[]];
copyWithin: (target: number, start: number, end?: number) => [SchemaIssue.Issue, ...SchemaIssue.Issue[]];
entries: () => ArrayIterator<[number, SchemaIssue.Issue]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<SchemaIssue.Issue>;
includes: (searchElement: SchemaIssue.Issue, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => SchemaIssue.Issue | undefined;
findLast: { (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => value is S, thisArg?: any): S | undefined; (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => unknown, thisA…;
findLastIndex: (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => unknown, thisArg?: any) => number;
toReversed: () => Array<SchemaIssue.Issue>;
toSorted: (compareFn?: ((a: SchemaIssue.Issue, b: SchemaIssue.Issue) => number) | undefined) => Array<SchemaIssue.Issue>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<SchemaIssue.Issue>): Array<SchemaIssue.Issue>; (start: number, deleteCount?: number): Array<SchemaIssue.Issue> };
with: (index: number, value: SchemaIssue.Issue) => Array<SchemaIssue.Issue>;
}
issues.push(const issue: SchemaIssue.Pointerconst issue: {
_tag: 'Pointer';
path: ReadonlyArray<PropertyKey>;
issue: Issue;
toString: (this: Issue) => string;
}
issue)
} else {
const state: {
ast: this
oinput: any
input: Record<PropertyKey, unknown>
out: Record<PropertyKey, unknown>
issues:
| Arr.NonEmptyArray<SchemaIssue.Issue>
| undefined
options: any
}
state.issues: anyissues = [const issue: SchemaIssue.Pointerconst issue: {
_tag: 'Pointer';
path: ReadonlyArray<PropertyKey>;
issue: Issue;
toString: (this: Issue) => string;
}
issue]
}
continue
} else {
return yield* import EffectEffect.fail(new import SchemaIssueSchemaIssue.constructor Composite(ast: AST, actual: Option.Option<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(const ast: thisast, oinput: Option.Some<unknown>(parameter) oinput: {
_tag: "Some";
_op: "Some";
value: A;
valueOrUndefined: A;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
oinput, [const issue: SchemaIssue.Pointerconst issue: {
_tag: 'Pointer';
path: ReadonlyArray<PropertyKey>;
issue: Issue;
toString: (this: Issue) => string;
}
issue]))
}
} else {
// preserve key
import internalRecordinternalRecord.function set<PropertyKey, unknown>(
self: Record<PropertyKey, unknown>,
key: PropertyKey,
value: unknown
): Record<PropertyKey, unknown>
set(const out: Record<PropertyKey, unknown>out, const key: PropertyKeykey, const input: Record<PropertyKey, unknown>input[const key: PropertyKeykey])
}
}
}
}
const const concurrency:
| {
concurrency: number
}
| undefined
concurrency = const resolveConcurrency: (
value: number | "unbounded" | undefined
) =>
| {
concurrency: number
}
| undefined
resolveConcurrency(options: ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options?.concurrency)
// ---------------------------------------------
// handle property signatures
// ---------------------------------------------
const const eff: anyeff = const parseProperties: (
initialState: {
readonly ast: AST
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
},
items: ReadonlyArray<ParsedProperty>,
options?: IterateEagerOptions
) =>
| Effect.Effect<void, SchemaIssue.Issue, any>
| undefined
parseProperties(const state: {
ast: this
oinput: any
input: Record<PropertyKey, unknown>
out: Record<PropertyKey, unknown>
issues:
| Arr.NonEmptyArray<SchemaIssue.Issue>
| undefined
options: any
}
state, const properties: Array<{
readonly ps: PropertySignature | IndexSignature
readonly parser: SchemaParser.Parser
readonly name: PropertyKey
readonly type: AST
}>
properties, const concurrency:
| {
concurrency: number
}
| undefined
concurrency)
if (const eff: anyeff) yield* const eff: Effect.Effect<
void,
SchemaIssue.Issue,
any
>
const eff: {
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; <…;
toString: () => string;
toJSON: () => unknown;
}
eff
// ---------------------------------------------
// handle index signatures
// ---------------------------------------------
if (const parseIndexes:
| ((
initialState: {
readonly oinput: Option.Option<unknown>
readonly input: Record<
PropertyKey,
unknown
>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues:
| Array<SchemaIssue.Issue>
| undefined
},
items: ReadonlyArray<
[key: PropertyKey, is: IndexSignature]
>,
options?: IterateEagerOptions
) =>
| Effect.Effect<
void,
SchemaIssue.Issue,
any
>
| undefined)
| undefined
parseIndexes) {
const const keyPairs: anykeyPairs = import ArrArr.empty<[type PropertyKey =
| string
| number
| symbol
PropertyKey, class IndexSignatureclass IndexSignature {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
Represents an index signature entry within an
Objects
node.
When to use
Use when constructing or inspecting object AST entries for record-like keys
and values.
Details
parameter — the key type AST (e.g.
String
for string keys,
TemplateLiteral
for patterned keys).
type — the value type SchemaAST.
merge — optional
KeyValueCombiner
for handling duplicate keys.
Gotchas
Using Schema.optionalKey on the value type is not allowed for index
signatures (throws at construction); use Schema.optional instead.
IndexSignature]>()
for (let let i: numberi = 0; let i: numberi < const indexCount: numberindexCount; let i: numberi++) {
const const is: IndexSignatureconst is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is = const ast: thisast.Objects.indexSignatures: ReadonlyArray<IndexSignature>indexSignatures[let i: numberi]
const const keys: readonly PropertyKey[]keys = function getIndexSignatureKeys(
input: { readonly [x: PropertyKey]: unknown },
parameter: IndexSignatureParameter,
options?: ParseOptions
): ReadonlyArray<PropertyKey>
Returns the object keys that match the index signature parameter schema.
getIndexSignatureKeys(const input: Record<PropertyKey, unknown>input, const is: IndexSignatureconst is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.IndexSignature.parameter: IndexSignatureParameterparameter, options: ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options)
for (let let j: numberj = 0; let j: numberj < const keys: readonly PropertyKey[]keys.ReadonlyArray<T>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length; let j: numberj++) {
const const key: PropertyKeykey = const keys: readonly PropertyKey[]keys[let j: numberj]
const keyPairs: anykeyPairs.push([const key: PropertyKeykey, const is: IndexSignatureconst is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is])
}
}
const const eff: anyeff = const parseIndexes: (
initialState: {
readonly oinput: Option.Option<unknown>
readonly input: Record<PropertyKey, unknown>
readonly options: ParseOptions
readonly out: Record<PropertyKey, unknown>
issues: Array<SchemaIssue.Issue> | undefined
},
items: ReadonlyArray<
[key: PropertyKey, is: IndexSignature]
>,
options?: IterateEagerOptions
) =>
| Effect.Effect<void, SchemaIssue.Issue, any>
| undefined
parseIndexes(const state: {
ast: this
oinput: any
input: Record<PropertyKey, unknown>
out: Record<PropertyKey, unknown>
issues:
| Arr.NonEmptyArray<SchemaIssue.Issue>
| undefined
options: any
}
state, const keyPairs: anykeyPairs, const concurrency:
| {
concurrency: number
}
| undefined
concurrency)
if (const eff: anyeff) yield* const eff: Effect.Effect<
void,
SchemaIssue.Issue,
any
>
const eff: {
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; <…;
toString: () => string;
toJSON: () => unknown;
}
eff
}
if (const state: {
ast: this
oinput: any
input: Record<PropertyKey, unknown>
out: Record<PropertyKey, unknown>
issues:
| Arr.NonEmptyArray<SchemaIssue.Issue>
| undefined
options: any
}
state.issues: anyissues) {
return yield* import EffectEffect.fail(new import SchemaIssueSchemaIssue.constructor Composite(ast: AST, actual: Option.Option<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(const ast: thisast, oinput: Option.Some<unknown>(parameter) oinput: {
_tag: "Some";
_op: "Some";
value: A;
valueOrUndefined: A;
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; <…;
toString: () => string;
toJSON: () => unknown;
}
oinput, const state: {
ast: this
oinput: any
input: Record<PropertyKey, unknown>
out: Record<PropertyKey, unknown>
issues:
| Arr.NonEmptyArray<SchemaIssue.Issue>
| undefined
options: any
}
state.issues: any(property) issues: {
0: SchemaIssue.Issue;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => SchemaIssue.Issue | undefined;
push: (...items: Array<SchemaIssue.Issue>) => number;
concat: { (...items: Array<ConcatArray<SchemaIssue.Issue>>): Array<SchemaIssue.Issue>; (...items: Array<SchemaIssue.Issue | ConcatArray<SchemaIssue.Issue>>): Array<SchemaIssue.Issue> };
join: (separator?: string) => string;
reverse: () => Array<SchemaIssue.Issue>;
shift: () => SchemaIssue.Issue | undefined;
slice: (start?: number, end?: number) => Array<SchemaIssue.Issue>;
sort: (compareFn?: ((a: SchemaIssue.Issue, b: SchemaIssue.Issue) => number) | undefined) => [SchemaIssue.Issue, ...SchemaIssue.Issue[]];
splice: { (start: number, deleteCount?: number): Array<SchemaIssue.Issue>; (start: number, deleteCount: number, ...items: Array<SchemaIssue.Issue>): Array<SchemaIssue.Issue> };
unshift: (...items: Array<SchemaIssue.Issue>) => number;
indexOf: (searchElement: SchemaIssue.Issue, fromIndex?: number) => number;
lastIndexOf: (searchElement: SchemaIssue.Issue, fromIndex?: number) => number;
every: { (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => value is S, thisArg?: any): this is S[]; (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => unknown, thisArg…;
some: (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => void, thisArg?: any) => void;
map: (callbackfn: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => value is S, thisArg?: any): Array<S>; (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => unknown, thisArg?: …;
reduce: { (callbackfn: (previousValue: SchemaIssue.Issue, currentValue: SchemaIssue.Issue, currentIndex: number, array: Array<SchemaIssue.Issue>) => SchemaIssue.Issue): SchemaIssue.Issue; (callbackfn: (previousValue: SchemaIssue.Issue, currentValu…;
reduceRight: { (callbackfn: (previousValue: SchemaIssue.Issue, currentValue: SchemaIssue.Issue, currentIndex: number, array: Array<SchemaIssue.Issue>) => SchemaIssue.Issue): SchemaIssue.Issue; (callbackfn: (previousValue: SchemaIssue.Issue, currentValu…;
find: { (predicate: (value: SchemaIssue.Issue, index: number, obj: Array<SchemaIssue.Issue>) => value is S, thisArg?: any): S | undefined; (predicate: (value: SchemaIssue.Issue, index: number, obj: Array<SchemaIssue.Issue>) => unknown, thisArg?:…;
findIndex: (predicate: (value: SchemaIssue.Issue, index: number, obj: Array<SchemaIssue.Issue>) => unknown, thisArg?: any) => number;
fill: (value: SchemaIssue.Issue, start?: number, end?: number) => [SchemaIssue.Issue, ...SchemaIssue.Issue[]];
copyWithin: (target: number, start: number, end?: number) => [SchemaIssue.Issue, ...SchemaIssue.Issue[]];
entries: () => ArrayIterator<[number, SchemaIssue.Issue]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<SchemaIssue.Issue>;
includes: (searchElement: SchemaIssue.Issue, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => SchemaIssue.Issue | undefined;
findLast: { (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => value is S, thisArg?: any): S | undefined; (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => unknown, thisA…;
findLastIndex: (predicate: (value: SchemaIssue.Issue, index: number, array: Array<SchemaIssue.Issue>) => unknown, thisArg?: any) => number;
toReversed: () => Array<SchemaIssue.Issue>;
toSorted: (compareFn?: ((a: SchemaIssue.Issue, b: SchemaIssue.Issue) => number) | undefined) => Array<SchemaIssue.Issue>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<SchemaIssue.Issue>): Array<SchemaIssue.Issue>; (start: number, deleteCount?: number): Array<SchemaIssue.Issue> };
with: (index: number, value: SchemaIssue.Issue) => Array<SchemaIssue.Issue>;
}
issues))
}
if (options: ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options.propertyOrder === "original") {
// preserve input keys order
const const keys: PropertyKey[]keys = (let inputKeys: PropertyKey[] | undefinedinputKeys ?? Reflect.function Reflect.ownKeys(target: object): (string | symbol)[]Returns the string and symbol keys of the own properties of an object. The own properties of an object
are those that are defined directly on that object, and are not inherited from the object's prototype.
ownKeys(const input: Record<PropertyKey, unknown>input)).Array<PropertyKey>.concat(...items: ConcatArray<PropertyKey>[]): PropertyKey[] (+1 overload)Combines two or more arrays.
This method returns a new array without modifying any existing arrays.
concat(const expectedKeys: PropertyKey[]expectedKeys)
const const preserved: Record<
PropertyKey,
unknown
>
preserved: type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<type PropertyKey =
| string
| number
| symbol
PropertyKey, unknown> = {}
for (const const key: PropertyKeykey of const keys: PropertyKey[]keys) {
if (var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.hasOwn(o: object, v: PropertyKey): booleanDetermines whether an object has a property with the specified name.
hasOwn(const out: Record<PropertyKey, unknown>out, const key: PropertyKeykey)) {
import internalRecordinternalRecord.function set<PropertyKey, unknown>(
self: Record<PropertyKey, unknown>,
key: PropertyKey,
value: unknown
): Record<PropertyKey, unknown>
set(const preserved: Record<
PropertyKey,
unknown
>
preserved, const key: PropertyKeykey, const out: Record<PropertyKey, unknown>out[const key: PropertyKeykey])
}
}
return import OptionOption.some(const preserved: Record<
PropertyKey,
unknown
>
preserved)
}
return import OptionOption.some(const out: Record<PropertyKey, unknown>out)
})
}
private Objects._rebuild(recur: (ast: AST) => AST, recurParameter: (ast: AST) => AST, flipMerge: boolean, checks: Checks | undefined, encodingChecks: Checks | undefined): Objects_rebuild(
recur: (ast: AST) => ASTrecur: (ast: ASTast: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) => type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST,
recurParameter: (ast: AST) => ASTrecurParameter: (ast: ASTast: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) => type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST,
flipMerge: booleanflipMerge: boolean,
checks: Checks | undefinedchecks: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks | undefined,
encodingChecks: Checks | undefinedencodingChecks: type Checks = readonly [
Check<any>,
...Check<any>[]
]
Non-empty array of validation
Check
values attached to an AST node
via
Base.checks
.
Details
Checks are run after basic type matching succeeds. They represent
refinements like minLength, pattern, int, etc.
Checks | undefined
): class Objectsclass Objects {
_tag: 'Objects';
propertySignatures: ReadonlyArray<PropertySignature>;
indexSignatures: ReadonlyArray<IndexSignature>;
encodingChecks: Checks | undefined;
getParser: (recur: (ast: AST) => SchemaParser.Parser) => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, recurParameter: (ast: AST) => AST, flipMerge: boolean, checks: Checks | undefined, encodingChecks: Checks | undefined) => Objects;
flip: (recur: (ast: AST) => AST) => AST;
recur: (recur: (ast: AST) => AST, recurParameter?: (ast: AST) => AST) => AST;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
AST node for object-like schemas, including structs and records.
When to use
Use when constructing or inspecting AST nodes for structs or records rather
than array-like schemas.
Details
propertySignatures — named properties with their types (struct fields).
indexSignatures — index signature entries (record patterns), each with
a parameter AST for matching keys and a type AST for values.
An Objects node with no properties and no index signatures performs only a
non-nullish check: it accepts any value except null and undefined,
including primitive values.
Gotchas
Duplicate property names throw at construction time.
Example (Inspecting a struct AST)
import { Schema, SchemaAST } from "effect"
const schema = Schema.Struct({ name: Schema.String })
const ast = schema.ast
if (SchemaAST.isObjects(ast)) {
for (const ps of ast.propertySignatures) {
console.log(ps.name, ps.type._tag)
}
// "name" "String"
}
Objects {
const const props: ReadonlyArray<PropertySignature>props = function mapOrSame<unknown>(as: Arr.NonEmptyReadonlyArray<unknown>, f: (a: unknown) => unknown): Arr.NonEmptyReadonlyArray<unknown> (+1 overload)Maps over the array but will return the original array if no changes occur.
mapOrSame(this.Objects.propertySignatures: ReadonlyArray<PropertySignature>propertySignatures, (ps: PropertySignature(parameter) ps: {
name: PropertyKey;
type: AST;
}
ps) => {
const const t: ASTt = recur: (ast: AST) => ASTrecur(ps: PropertySignature(parameter) ps: {
name: PropertyKey;
type: AST;
}
ps.type)
return const t: ASTt === ps: PropertySignature(parameter) ps: {
name: PropertyKey;
type: AST;
}
ps.type ? ps: PropertySignature(parameter) ps: {
name: PropertyKey;
type: AST;
}
ps : new constructor PropertySignature(name: PropertyKey, type: AST): PropertySignaturePropertySignature(ps: PropertySignature(parameter) ps: {
name: PropertyKey;
type: AST;
}
ps.name, const t: ASTt)
})
const const indexes: ReadonlyArray<IndexSignature>indexes = function mapOrSame<unknown>(as: Arr.NonEmptyReadonlyArray<unknown>, f: (a: unknown) => unknown): Arr.NonEmptyReadonlyArray<unknown> (+1 overload)Maps over the array but will return the original array if no changes occur.
mapOrSame(this.Objects.indexSignatures: ReadonlyArray<IndexSignature>indexSignatures, (is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is) => {
const const p: ASTp = recurParameter: (ast: AST) => ASTrecurParameter(is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.parameter)
const const t: ASTt = recur: (ast: AST) => ASTrecur(is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.type)
const const merge: anymerge = flipMerge: booleanflipMerge ? is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.merge?.flip() : is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.merge
return const p: ASTp === is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.parameter && const t: ASTt === is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.type && const merge: anymerge === is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is.merge
? is: IndexSignature(parameter) is: {
parameter: IndexSignatureParameter;
type: AST;
merge: KeyValueCombiner | undefined;
}
is
: new constructor IndexSignature(parameter: AST, type: AST, merge: KeyValueCombiner | undefined): IndexSignatureRepresents an index signature entry within an
Objects
node.
When to use
Use when constructing or inspecting object AST entries for record-like keys
and values.
Details
parameter — the key type AST (e.g.
String
for string keys,
TemplateLiteral
for patterned keys).
type — the value type SchemaAST.
merge — optional
KeyValueCombiner
for handling duplicate keys.
Gotchas
Using Schema.optionalKey on the value type is not allowed for index
signatures (throws at construction); use Schema.optional instead.
IndexSignature(const p: ASTp, const t: ASTt, const merge: anymerge)
})
return const props: ReadonlyArray<PropertySignature>props === this.Objects.propertySignatures: ReadonlyArray<PropertySignature>propertySignatures && const indexes: ReadonlyArray<IndexSignature>indexes === this.Objects.indexSignatures: ReadonlyArray<IndexSignature>indexSignatures && checks: Checks | undefinedchecks === this.Base.checks: Checks | undefinedchecks &&
encodingChecks: Checks | undefinedencodingChecks === this.Objects.encodingChecks: Checks | undefinedencodingChecks
? this
: new constructor Objects(propertySignatures: ReadonlyArray<PropertySignature>, indexSignatures: ReadonlyArray<IndexSignature>, annotations?: Schema.Annotations.Annotations, checks?: Checks, encoding?: Encoding, context?: Context, encodingChecks?: Checks): ObjectsAST node for object-like schemas, including structs and records.
When to use
Use when constructing or inspecting AST nodes for structs or records rather
than array-like schemas.
Details
propertySignatures — named properties with their types (struct fields).
indexSignatures — index signature entries (record patterns), each with
a parameter AST for matching keys and a type AST for values.
An Objects node with no properties and no index signatures performs only a
non-nullish check: it accepts any value except null and undefined,
including primitive values.
Gotchas
Duplicate property names throw at construction time.
Example (Inspecting a struct AST)
import { Schema, SchemaAST } from "effect"
const schema = Schema.Struct({ name: Schema.String })
const ast = schema.ast
if (SchemaAST.isObjects(ast)) {
for (const ps of ast.propertySignatures) {
console.log(ps.name, ps.type._tag)
}
// "name" "String"
}
Objects(
const props: ReadonlyArray<PropertySignature>props,
const indexes: ReadonlyArray<IndexSignature>indexes,
this.Base.annotations: anyannotations,
checks: Checks | undefinedchecks,
var undefinedundefined,
this.Base.context: Context | undefinedcontext,
encodingChecks: Checks | undefinedencodingChecks
)
}
/** @internal */
Objects.flip(recur: (ast: AST) => AST): ASTflip(recur: (ast: AST) => ASTrecur: (ast: ASTast: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) => type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST): type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST {
return this.Objects._rebuild(recur: (ast: AST) => AST, recurParameter: (ast: AST) => AST, flipMerge: boolean, checks: Checks | undefined, encodingChecks: Checks | undefined): Objects_rebuild(recur: (ast: AST) => ASTrecur, recur: (ast: AST) => ASTrecur, true, this.Objects.encodingChecks: Checks | undefinedencodingChecks, this.Base.checks: Checks | undefinedchecks)
}
/** @internal */
Objects.recur(recur: (ast: AST) => AST, recurParameter?: (ast: AST) => AST): ASTrecur(recur: (ast: AST) => ASTrecur: (ast: ASTast: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) => type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST, recurParameter: (ast: AST) => ASTrecurParameter: (ast: ASTast: type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST) => type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST = recur: (ast: AST) => ASTrecur): type AST =
| Declaration
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union<AST>
| Suspend
Discriminated union of all AST node types.
Details
Every Schema has an .ast property of this type. Use the guard functions
(
isString
,
isObjects
, etc.) to narrow to a specific variant,
then access variant-specific fields.
- All variants share the
Base
fields:
annotations, checks,
encoding, context.
- Discriminate on the
_tag field (e.g. "String", "Objects", "Union").
AST {
return this.Objects._rebuild(recur: (ast: AST) => AST, recurParameter: (ast: AST) => AST, flipMerge: boolean, checks: Checks | undefined, encodingChecks: Checks | undefined): Objects_rebuild(recur: (ast: AST) => ASTrecur, recurParameter: (ast: AST) => ASTrecurParameter, false, this.Base.checks: Checks | undefinedchecks, this.Objects.encodingChecks: Checks | undefinedencodingChecks)
}
/** @internal */
Objects.getExpected(): stringgetExpected(): string {
if (this.Objects.propertySignatures: ReadonlyArray<PropertySignature>propertySignatures.ReadonlyArray<T>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length === 0 && this.Objects.indexSignatures: ReadonlyArray<IndexSignature>indexSignatures.ReadonlyArray<T>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length === 0) return "object | array"
return "object"
}
}