/**
* @since 3.10.0
*/
import * as Arr from "./Array.js";
import * as Cause from "./Cause.js";
import * as Effect from "./Effect.js";
import * as Either from "./Either.js";
import type { LazyArg } from "./Function.js";
import * as Inspectable from "./Inspectable.js";
import * as Option from "./Option.js";
import type * as Schema from "./Schema.js";
import * as AST from "./SchemaAST.js";
/**
* `ParseIssue` is a type that represents the different types of errors that can occur when decoding/encoding a value.
*
* @category model
* @since 3.10.0
*/
export type ParseIssue = Type | Missing | Unexpected | Forbidden | Pointer | Refinement | Transformation | Composite;
/**
* @category model
* @since 3.10.0
*/
export type SingleOrNonEmpty = A | Arr.NonEmptyReadonlyArray;
/**
* @category model
* @since 3.10.0
*/
export type Path = SingleOrNonEmpty;
/**
* @category model
* @since 3.10.0
*/
export declare class Pointer {
readonly path: Path;
readonly actual: unknown;
readonly issue: ParseIssue;
/**
* @since 3.10.0
*/
readonly _tag = "Pointer";
constructor(path: Path, actual: unknown, issue: ParseIssue);
}
/**
* Error that occurs when an unexpected key or index is present.
*
* @category model
* @since 3.10.0
*/
export declare class Unexpected {
readonly actual: unknown;
/**
* @since 3.10.0
*/
readonly message?: string | undefined;
/**
* @since 3.10.0
*/
readonly _tag = "Unexpected";
constructor(actual: unknown,
/**
* @since 3.10.0
*/
message?: string | undefined);
}
/**
* Error that occurs when a required key or index is missing.
*
* @category model
* @since 3.10.0
*/
export declare class Missing {
/**
* @since 3.10.0
*/
readonly ast: AST.Type;
/**
* @since 3.10.0
*/
readonly message?: string | undefined;
/**
* @since 3.10.0
*/
readonly _tag = "Missing";
/**
* @since 3.10.0
*/
readonly actual: undefined;
constructor(
/**
* @since 3.10.0
*/
ast: AST.Type,
/**
* @since 3.10.0
*/
message?: string | undefined);
}
/**
* Error that contains multiple issues.
*
* @category model
* @since 3.10.0
*/
export declare class Composite {
readonly ast: AST.AST;
readonly actual: unknown;
readonly issues: SingleOrNonEmpty;
readonly output?: unknown | undefined;
/**
* @since 3.10.0
*/
readonly _tag = "Composite";
constructor(ast: AST.AST, actual: unknown, issues: SingleOrNonEmpty, output?: unknown | undefined);
}
/**
* Error that occurs when a refinement has an error.
*
* @category model
* @since 3.10.0
*/
export declare class Refinement {
readonly ast: AST.Refinement;
readonly actual: unknown;
readonly kind: "From" | "Predicate";
readonly issue: ParseIssue;
/**
* @since 3.10.0
*/
readonly _tag = "Refinement";
constructor(ast: AST.Refinement, actual: unknown, kind: "From" | "Predicate", issue: ParseIssue);
}
/**
* Error that occurs when a transformation has an error.
*
* @category model
* @since 3.10.0
*/
export declare class Transformation {
readonly ast: AST.Transformation;
readonly actual: unknown;
readonly kind: "Encoded" | "Transformation" | "Type";
readonly issue: ParseIssue;
/**
* @since 3.10.0
*/
readonly _tag = "Transformation";
constructor(ast: AST.Transformation, actual: unknown, kind: "Encoded" | "Transformation" | "Type", issue: ParseIssue);
}
/**
* The `Type` variant of the `ParseIssue` type represents an error that occurs when the `actual` value is not of the expected type.
* The `ast` field specifies the expected type, and the `actual` field contains the value that caused the error.
*
* @category model
* @since 3.10.0
*/
export declare class Type {
readonly ast: AST.AST;
readonly actual: unknown;
readonly message?: string | undefined;
/**
* @since 3.10.0
*/
readonly _tag = "Type";
constructor(ast: AST.AST, actual: unknown, message?: string | undefined);
}
/**
* The `Forbidden` variant of the `ParseIssue` type represents a forbidden operation, such as when encountering an Effect that is not allowed to execute (e.g., using `runSync`).
*
* @category model
* @since 3.10.0
*/
export declare class Forbidden {
readonly ast: AST.AST;
readonly actual: unknown;
readonly message?: string | undefined;
/**
* @since 3.10.0
*/
readonly _tag = "Forbidden";
constructor(ast: AST.AST, actual: unknown, message?: string | undefined);
}
/**
* @category type id
* @since 3.10.0
*/
export declare const ParseErrorTypeId: unique symbol;
/**
* @category type id
* @since 3.10.0
*/
export type ParseErrorTypeId = typeof ParseErrorTypeId;
/**
* @since 3.10.0
*/
export declare const isParseError: (u: unknown) => u is ParseError;
declare const ParseError_base: new = {}>(args: import("./Types.js").Equals extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Cause.YieldableError & {
readonly _tag: "ParseError";
} & Readonly;
/**
* @since 3.10.0
*/
export declare class ParseError extends ParseError_base<{
readonly issue: ParseIssue;
}> {
/**
* @since 3.10.0
*/
readonly [ParseErrorTypeId]: symbol;
get message(): string;
/**
* @since 3.10.0
*/
toString(): string;
/**
* @since 3.10.0
*/
toJSON(): {
_id: string;
message: string;
};
/**
* @since 3.10.0
*/
[Inspectable.NodeInspectSymbol](): {
_id: string;
message: string;
};
}
/**
* @category constructors
* @since 3.10.0
*/
export declare const parseError: (issue: ParseIssue) => ParseError;
/**
* @category constructors
* @since 3.10.0
*/
export declare const succeed: (a: A) => Either.Either;
/**
* @category constructors
* @since 3.10.0
*/
export declare const fail: (issue: ParseIssue) => Either.Either;
declare const _try: (options: {
try: LazyArg;
catch: (e: unknown) => ParseIssue;
}) => Either.Either;
export {
/**
* @category constructors
* @since 3.10.0
*/
_try as try };
/**
* @category constructors
* @since 3.10.0
*/
export declare const fromOption: {
/**
* @category constructors
* @since 3.10.0
*/
(onNone: () => ParseIssue): (self: Option.Option) => Either.Either;
/**
* @category constructors
* @since 3.10.0
*/
(self: Option.Option, onNone: () => ParseIssue): Either.Either;
};
/**
* @category optimisation
* @since 3.10.0
*/
export declare const flatMap: {
/**
* @category optimisation
* @since 3.10.0
*/
(f: (a: A) => Effect.Effect): (self: Effect.Effect) => Effect.Effect;
/**
* @category optimisation
* @since 3.10.0
*/
(self: Effect.Effect, f: (a: A) => Effect.Effect): Effect.Effect;
};
/**
* @category optimisation
* @since 3.10.0
*/
export declare const map: {
/**
* @category optimisation
* @since 3.10.0
*/
(f: (a: A) => B): (self: Effect.Effect) => Effect.Effect;
/**
* @category optimisation
* @since 3.10.0
*/
(self: Effect.Effect, f: (a: A) => B): Effect.Effect;
};
/**
* @category optimisation
* @since 3.10.0
*/
export declare const mapError: {
/**
* @category optimisation
* @since 3.10.0
*/
(f: (e: E) => E2): (self: Effect.Effect) => Effect.Effect;
/**
* @category optimisation
* @since 3.10.0
*/
(self: Effect.Effect, f: (e: E) => E2): Effect.Effect;
};
/**
* @category optimisation
* @since 3.10.0
*/
export declare const eitherOrUndefined: (self: Effect.Effect) => Either.Either | undefined;
/**
* @category optimisation
* @since 3.10.0
*/
export declare const mapBoth: {
/**
* @category optimisation
* @since 3.10.0
*/
(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Effect.Effect) => Effect.Effect;
/**
* @category optimisation
* @since 3.10.0
*/
(self: Effect.Effect, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Effect.Effect;
};
/**
* @category optimisation
* @since 3.10.0
*/
export declare const orElse: {
/**
* @category optimisation
* @since 3.10.0
*/
(f: (e: E) => Effect.Effect): (self: Effect.Effect) => Effect.Effect;
/**
* @category optimisation
* @since 3.10.0
*/
(self: Effect.Effect, f: (e: E) => Effect.Effect): Effect.Effect;
};
/**
* @since 3.10.0
*/
export type DecodeUnknown = (u: unknown, options?: AST.ParseOptions) => Effect.Effect;
/**
* @since 3.10.0
*/
export type DeclarationDecodeUnknown = (u: unknown, options: AST.ParseOptions, ast: AST.Declaration) => Effect.Effect;
/**
* @throws `ParseError`
* @category decoding
* @since 3.10.0
*/
export declare const decodeUnknownSync: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => A;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeUnknownOption: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Option.Option;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeUnknownEither: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Either.Either;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeUnknownPromise: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Promise;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeUnknown: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Effect.Effect;
/**
* @throws `ParseError`
* @category encoding
* @since 3.10.0
*/
export declare const encodeUnknownSync: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => I;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeUnknownOption: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Option.Option;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeUnknownEither: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Either.Either;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeUnknownPromise: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Promise;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeUnknown: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Effect.Effect;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeSync: (schema: Schema.Schema, options?: AST.ParseOptions) => (i: I, overrideOptions?: AST.ParseOptions) => A;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeOption: (schema: Schema.Schema, options?: AST.ParseOptions) => (i: I, overrideOptions?: AST.ParseOptions) => Option.Option;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeEither: (schema: Schema.Schema, options?: AST.ParseOptions) => (i: I, overrideOptions?: AST.ParseOptions) => Either.Either;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodePromise: (schema: Schema.Schema, options?: AST.ParseOptions) => (i: I, overrideOptions?: AST.ParseOptions) => Promise;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decode: (schema: Schema.Schema, options?: AST.ParseOptions) => (i: I, overrideOptions?: AST.ParseOptions) => Effect.Effect;
/**
* @throws `ParseError`
* @category validation
* @since 3.10.0
*/
export declare const validateSync: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => A;
/**
* @category validation
* @since 3.10.0
*/
export declare const validateOption: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Option.Option;
/**
* @category validation
* @since 3.10.0
*/
export declare const validateEither: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Either.Either;
/**
* @category validation
* @since 3.10.0
*/
export declare const validatePromise: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => Promise;
/**
* @category validation
* @since 3.10.0
*/
export declare const validate: (schema: Schema.Schema, options?: AST.ParseOptions) => (a: unknown, overrideOptions?: AST.ParseOptions) => Effect.Effect;
/**
* By default the option `exact` is set to `true`.
*
* @category validation
* @since 3.10.0
*/
export declare const is: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions | number) => u is A;
/**
* By default the option `exact` is set to `true`.
*
* @throws `ParseError`
* @category validation
* @since 3.10.0
*/
export declare const asserts: (schema: Schema.Schema, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => asserts u is A;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeSync: (schema: Schema.Schema, options?: AST.ParseOptions) => (a: A, overrideOptions?: AST.ParseOptions) => I;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeOption: (schema: Schema.Schema, options?: AST.ParseOptions) => (input: A, overrideOptions?: AST.ParseOptions) => Option.Option;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeEither: (schema: Schema.Schema, options?: AST.ParseOptions) => (a: A, overrideOptions?: AST.ParseOptions) => Either.Either;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodePromise: (schema: Schema.Schema, options?: AST.ParseOptions) => (a: A, overrideOptions?: AST.ParseOptions) => Promise;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encode: (schema: Schema.Schema, options?: AST.ParseOptions) => (a: A, overrideOptions?: AST.ParseOptions) => Effect.Effect;
/**
* @category formatting
* @since 3.10.0
*/
export interface ParseResultFormatter {
readonly formatIssue: (issue: ParseIssue) => Effect.Effect;
readonly formatIssueSync: (issue: ParseIssue) => A;
readonly formatError: (error: ParseError) => Effect.Effect;
readonly formatErrorSync: (error: ParseError) => A;
}
/**
* @category formatting
* @since 3.10.0
*/
export declare const TreeFormatter: ParseResultFormatter;
/**
* Returns `true` if the value is a `Composite`.
*
* @category guards
* @since 3.10.0
*/
export declare const isComposite: (issue: ParseIssue) => issue is Composite;
/**
* Represents an issue returned by the {@link ArrayFormatter} formatter.
*
* @category model
* @since 3.10.0
*/
export interface ArrayFormatterIssue {
/**
* The tag identifying the type of parse issue.
*/
readonly _tag: ParseIssue["_tag"];
/**
* The path to the property where the issue occurred.
*/
readonly path: ReadonlyArray;
/**
* A descriptive message explaining the issue.
*/
readonly message: string;
}
/**
* @category formatting
* @since 3.10.0
*/
export declare const ArrayFormatter: ParseResultFormatter>;
//# sourceMappingURL=ParseResult.d.ts.map