ParseResult
Constructors
Signature
declare const fail: (issue: ParseIssue) => Either.Either<never, ParseIssue>;fromOption
Signature
declare const fromOption: {
(onNone: () => ParseIssue): <A>(self: Option<A>) => Either<A, ParseIssue>;
<A>(self: Option<A>, onNone: () => ParseIssue): Either<A, ParseIssue>;
};parseError
Signature
declare function parseError(issue: ParseIssue): ParseError;Signature
declare const succeed: <A>(a: A) => Either.Either<A, ParseIssue>;Decoding
Signature
declare const decode: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions,
) => (i: I, overrideOptions?: AST.ParseOptions) => Effect.Effect<A, ParseIssue, R>;decodeEither
Signature
declare const decodeEither: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions,
) => (i: I, overrideOptions?: AST.ParseOptions) => Either.Either<A, ParseIssue>;decodeOption
Signature
declare const decodeOption: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions,
) => (i: I, overrideOptions?: AST.ParseOptions) => Option.Option<A>;decodePromise
Signature
declare const decodePromise: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions,
) => (i: I, overrideOptions?: AST.ParseOptions) => Promise<A>;decodeSync
Signature
declare const decodeSync: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions,
) => (i: I, overrideOptions?: AST.ParseOptions) => A;decodeUnknown
Signature
declare function decodeUnknown<A, I, R>(
schema: Schema<A, I, R>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Effect<A, ParseIssue, R>;decodeUnknownEither
Signature
declare function decodeUnknownEither<A, I>(
schema: Schema<A, I, never>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Either<A, ParseIssue>;decodeUnknownOption
Signature
declare function decodeUnknownOption<A, I>(
schema: Schema<A, I, never>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Option<A>;decodeUnknownPromise
Signature
declare function decodeUnknownPromise<A, I>(
schema: Schema<A, I, never>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Promise<A>;decodeUnknownSync
Signature
declare function decodeUnknownSync<A, I>(
schema: Schema<A, I, never>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => A;Encoding
Signature
declare const encode: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions,
) => (a: A, overrideOptions?: AST.ParseOptions) => Effect.Effect<I, ParseIssue, R>;encodeEither
Signature
declare const encodeEither: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions,
) => (a: A, overrideOptions?: AST.ParseOptions) => Either.Either<I, ParseIssue>;encodeOption
Signature
declare const encodeOption: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions,
) => (input: A, overrideOptions?: AST.ParseOptions) => Option.Option<I>;encodePromise
Signature
declare const encodePromise: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions,
) => (a: A, overrideOptions?: AST.ParseOptions) => Promise<I>;encodeSync
Signature
declare const encodeSync: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions,
) => (a: A, overrideOptions?: AST.ParseOptions) => I;encodeUnknown
Signature
declare function encodeUnknown<A, I, R>(
schema: Schema<A, I, R>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Effect<I, ParseIssue, R>;encodeUnknownEither
Signature
declare function encodeUnknownEither<A, I>(
schema: Schema<A, I, never>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Either<I, ParseIssue>;encodeUnknownOption
Signature
declare function encodeUnknownOption<A, I>(
schema: Schema<A, I, never>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Option<I>;encodeUnknownPromise
Signature
declare function encodeUnknownPromise<A, I>(
schema: Schema<A, I, never>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Promise<I>;encodeUnknownSync
Signature
declare function encodeUnknownSync<A, I>(
schema: Schema<A, I, never>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => I;Formatting
ArrayFormatter
Signature
declare const ArrayFormatter: ParseResultFormatter<Array<ArrayFormatterIssue>>;ParseResultFormatter interface
Signature
interface ParseResultFormatter<A> {
readonly formatError: (error: ParseError) => Effect<A>;
readonly formatErrorSync: (error: ParseError) => A;
readonly formatIssue: (issue: ParseIssue) => Effect<A>;
readonly formatIssueSync: (issue: ParseIssue) => A;
}TreeFormatter
Signature
declare const TreeFormatter: ParseResultFormatter<string>;Guards
isComposite
Signature
declare const isComposite: (issue: ParseIssue) => issue is Composite;Model
ArrayFormatterIssue interface
Represents an issue returned by the ArrayFormatter formatter.
Signature
interface ArrayFormatterIssue {
readonly _tag: "Composite" | "Pointer" | "Unexpected" | "Missing" | "Refinement" | "Transformation" | "Type" | "Forbidden";
readonly message: string;
readonly path: readonly Array<PropertyKey>;
}Error that contains multiple issues.
Signature
declare class Composite {
constructor(ast: AST, actual: unknown, issues: SingleOrNonEmpty<ParseIssue>, output?: unknown);
readonly _tag: "Composite";
readonly actual: unknown;
readonly ast: AST;
readonly issues: SingleOrNonEmpty<ParseIssue>;
readonly output?: unknown;
}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).
Signature
declare class Forbidden {
constructor(ast: AST, actual: unknown, message?: string);
readonly _tag: "Forbidden";
readonly actual: unknown;
readonly ast: AST;
readonly message?: string;
}Error that occurs when a required key or index is missing.
Signature
declare class Missing {
constructor(ast: Type, message?: string);
readonly _tag: "Missing";
readonly actual: undefined;
readonly ast: Type;
readonly message?: string;
}ParseIssue type
ParseIssue is a type that represents the different types of errors that can occur when decoding/encoding a value.
Signature
type ParseIssue =
| Type
| Missing
| Unexpected
| Forbidden
| Pointer
| Refinement
| Transformation
| Composite;Signature
type Path = SingleOrNonEmpty<PropertyKey>;Signature
declare class Pointer {
constructor(path: Path, actual: unknown, issue: ParseIssue);
readonly _tag: "Pointer";
readonly actual: unknown;
readonly issue: ParseIssue;
readonly path: Path;
}Refinement
Error that occurs when a refinement has an error.
Signature
declare class Refinement {
constructor(ast: Refinement, actual: unknown, kind: "From" | "Predicate", issue: ParseIssue);
readonly _tag: "Refinement";
readonly actual: unknown;
readonly ast: Refinement;
readonly issue: ParseIssue;
readonly kind: "From" | "Predicate";
}SingleOrNonEmpty type
Signature
type SingleOrNonEmpty<A> = A | Arr.NonEmptyReadonlyArray<A>;Transformation
Error that occurs when a transformation has an error.
Signature
declare class Transformation {
constructor(
ast: Transformation,
actual: unknown,
kind: "Encoded" | "Transformation" | "Type",
issue: ParseIssue,
);
readonly _tag: "Transformation";
readonly actual: unknown;
readonly ast: Transformation;
readonly issue: ParseIssue;
readonly kind: "Encoded" | "Transformation" | "Type";
}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.
Signature
declare class Type {
constructor(ast: AST, actual: unknown, message?: string);
readonly _tag: "Type";
readonly actual: unknown;
readonly ast: AST;
readonly message?: string;
}Unexpected
Error that occurs when an unexpected key or index is present.
Signature
declare class Unexpected {
constructor(actual: unknown, message?: string);
readonly _tag: "Unexpected";
readonly actual: unknown;
readonly message?: string;
}Optimisation
eitherOrUndefined
Signature
declare function eitherOrUndefined<A, E, R>(self: Effect<A, E, R>): Either<A, E> | undefined;Signature
declare const flatMap: {
<A, B, E1, R1>(
f: (a: A) => Effect<B, E1, R1>,
): <E, R>(self: Effect<A, E, R>) => Effect<B, E1 | E, R1 | R>;
<A, E, R, B, E1, R1>(
self: Effect<A, E, R>,
f: (a: A) => Effect<B, E1, R1>,
): Effect<B, E | E1, R | R1>;
};Signature
declare const map: {
<A, B>(f: (a: A) => B): <E, R>(self: Effect<A, E, R>) => Effect<B, E, R>;
<A, E, R, B>(self: Effect<A, E, R>, f: (a: A) => B): Effect<B, E, R>;
};Signature
declare const mapBoth: {
<E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): <R>(self: Effect<A, E, R>) => Effect<A2, E2, R>;
<A, E, R, E2, A2>(
self: Effect<A, E, R>,
options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
},
): Effect<A2, E2, R>;
};Signature
declare const mapError: {
<E, E2>(f: (e: E) => E2): <A, R>(self: Effect<A, E, R>) => Effect<A, E2, R>;
<A, E, R, E2>(self: Effect<A, E, R>, f: (e: E) => E2): Effect<A, E2, R>;
};Signature
declare const orElse: {
<E, A2, E2, R2>(
f: (e: E) => Effect<A2, E2, R2>,
): <A, R>(self: Effect<A, E, R>) => Effect<A2 | A, E2, R2 | R>;
<A, E, R, A2, E2, R2>(
self: Effect<A, E, R>,
f: (e: E) => Effect<A2, E2, R2>,
): Effect<A | A2, E2, R | R2>;
};Other
DeclarationDecodeUnknown type
Signature
type DeclarationDecodeUnknown<Out, R> = (
u: unknown,
options: AST.ParseOptions,
ast: AST.Declaration,
) => Effect.Effect<Out, ParseIssue, R>;DecodeUnknown type
Signature
type DecodeUnknown<Out, R> = (
u: unknown,
options?: AST.ParseOptions,
) => Effect.Effect<Out, ParseIssue, R>;isParseError
Signature
declare function isParseError(u: unknown): u is ParseError;ParseError
Signature
declare class ParseError extends YieldableError<this> & {
readonly _tag: "ParseError";
} & Readonly<{
readonly issue: ParseIssue;
}> {
constructor(args: {
readonly issue: ParseIssue;
});
readonly [ParseErrorTypeId]: symbol;
message: string;
[NodeInspectSymbol](): {
_id: string;
message: string;
};
toJSON(): {
_id: string;
message: string;
};
toString(): string;
}Signature
declare const try: <A>(options: {
catch: (e: unknown) => ParseIssue;
try: LazyArg<A>;
}) => Either.Either<A, ParseIssue>Type Id
ParseErrorTypeId
Signature
declare const ParseErrorTypeId: unique symbol;ParseErrorTypeId type
Signature
type ParseErrorTypeId = typeof ParseErrorTypeId;Validation
By default the option exact is set to true.
Signature
declare function asserts<A, I, R>(
schema: Schema<A, I, R>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => asserts u is A;By default the option exact is set to true.
Signature
declare function is<A, I, R>(
schema: Schema<A, I, R>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: number | ParseOptions) => u is A;Signature
declare function validate<A, I, R>(
schema: Schema<A, I, R>,
options?: ParseOptions,
): (a: unknown, overrideOptions?: ParseOptions) => Effect<A, ParseIssue, R>;validateEither
Signature
declare function validateEither<A, I, R>(
schema: Schema<A, I, R>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Either<A, ParseIssue>;validateOption
Signature
declare function validateOption<A, I, R>(
schema: Schema<A, I, R>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Option<A>;validatePromise
Signature
declare function validatePromise<A, I>(
schema: Schema<A, I, never>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => Promise<A>;validateSync
Signature
declare function validateSync<A, I, R>(
schema: Schema<A, I, R>,
options?: ParseOptions,
): (u: unknown, overrideOptions?: ParseOptions) => A;
Returns
trueif the value is aComposite.