ParseResult.ts overview
Since v3.10.0
Exports Grouped by Category
- constructors
- decoding
- encoding
- formatting
- guards
- model
- optimisation
- type id
- utils
- validation
constructors
fail
Signature
declare const fail: (issue: ParseIssue) => Either.Either<never, ParseIssue>
Since v3.10.0
fromOption
Signature
declare const fromOption: {
(onNone: () => ParseIssue): <A>(self: Option.Option<A>) => Either.Either<A, ParseIssue>
<A>(self: Option.Option<A>, onNone: () => ParseIssue): Either.Either<A, ParseIssue>
}
Since v3.10.0
parseError
Signature
declare const parseError: (issue: ParseIssue) => ParseError
Since v3.10.0
succeed
Signature
declare const succeed: <A>(a: A) => Either.Either<A, ParseIssue>
Since v3.10.0
try
Signature
declare const try: <A>(options: { try: LazyArg<A>; catch: (e: unknown) => ParseIssue; }) => Either.Either<A, ParseIssue>
Since v3.10.0
decoding
decode
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>
Since v3.10.0
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>
Since v3.10.0
decodeOption
Signature
declare const decodeOption: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (i: I, overrideOptions?: AST.ParseOptions) => Option.Option<A>
Since v3.10.0
decodePromise
Signature
declare const decodePromise: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (i: I, overrideOptions?: AST.ParseOptions) => Promise<A>
Since v3.10.0
decodeSync
Signature
declare const decodeSync: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (i: I, overrideOptions?: AST.ParseOptions) => A
Since v3.10.0
decodeUnknown
Signature
declare const decodeUnknown: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Effect.Effect<A, ParseIssue, R>
Since v3.10.0
decodeUnknownEither
Signature
declare const decodeUnknownEither: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Either.Either<A, ParseIssue>
Since v3.10.0
decodeUnknownOption
Signature
declare const decodeUnknownOption: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Option.Option<A>
Since v3.10.0
decodeUnknownPromise
Signature
declare const decodeUnknownPromise: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Promise<A>
Since v3.10.0
decodeUnknownSync
Throws
ParseError
Signature
declare const decodeUnknownSync: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => A
Since v3.10.0
encoding
encode
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>
Since v3.10.0
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>
Since v3.10.0
encodeOption
Signature
declare const encodeOption: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (input: A, overrideOptions?: AST.ParseOptions) => Option.Option<I>
Since v3.10.0
encodePromise
Signature
declare const encodePromise: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (a: A, overrideOptions?: AST.ParseOptions) => Promise<I>
Since v3.10.0
encodeSync
Signature
declare const encodeSync: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (a: A, overrideOptions?: AST.ParseOptions) => I
Since v3.10.0
encodeUnknown
Signature
declare const encodeUnknown: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Effect.Effect<I, ParseIssue, R>
Since v3.10.0
encodeUnknownEither
Signature
declare const encodeUnknownEither: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Either.Either<I, ParseIssue>
Since v3.10.0
encodeUnknownOption
Signature
declare const encodeUnknownOption: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Option.Option<I>
Since v3.10.0
encodeUnknownPromise
Signature
declare const encodeUnknownPromise: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Promise<I>
Since v3.10.0
encodeUnknownSync
Throws
ParseError
Signature
declare const encodeUnknownSync: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => I
Since v3.10.0
formatting
ArrayFormatter
Signature
declare const ArrayFormatter: ParseResultFormatter<Array<ArrayFormatterIssue>>
Since v3.10.0
ParseResultFormatter (interface)
Signature
export interface ParseResultFormatter<A> {
readonly formatIssue: (issue: ParseIssue) => Effect.Effect<A>
readonly formatIssueSync: (issue: ParseIssue) => A
readonly formatError: (error: ParseError) => Effect.Effect<A>
readonly formatErrorSync: (error: ParseError) => A
}
Since v3.10.0
TreeFormatter
Signature
declare const TreeFormatter: ParseResultFormatter<string>
Since v3.10.0
guards
isComposite
Returns true
if the value is a Composite
.
Signature
declare const isComposite: (issue: ParseIssue) => issue is Composite
Since v3.10.0
model
ArrayFormatterIssue (interface)
Represents an issue returned by the ArrayFormatter
formatter.
Signature
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<PropertyKey>
/**
* A descriptive message explaining the issue.
*/
readonly message: string
}
Since v3.10.0
Composite (class)
Error that contains multiple issues.
Signature
declare class Composite { constructor(
readonly ast: AST.AST,
readonly actual: unknown,
readonly issues: SingleOrNonEmpty<ParseIssue>,
readonly output?: unknown
) }
Since v3.10.0
_tag (property)
Signature
readonly _tag: "Composite"
Since v3.10.0
Forbidden (class)
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(
readonly ast: AST.AST,
readonly actual: unknown,
readonly message?: string
) }
Since v3.10.0
_tag (property)
Signature
readonly _tag: "Forbidden"
Since v3.10.0
Missing (class)
Error that occurs when a required key or index is missing.
Signature
declare class Missing { constructor(
/**
* @since 3.10.0
*/
readonly ast: AST.Type,
/**
* @since 3.10.0
*/
readonly message?: string
) }
Since v3.10.0
_tag (property)
Signature
readonly _tag: "Missing"
Since v3.10.0
actual (property)
Signature
readonly actual: undefined
Since v3.10.0
ParseIssue (type alias)
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
// composite
| Pointer
| Refinement
| Transformation
| Composite
Since v3.10.0
Path (type alias)
Signature
type Path = SingleOrNonEmpty<PropertyKey>
Since v3.10.0
Pointer (class)
Signature
declare class Pointer { constructor(
readonly path: Path,
readonly actual: unknown,
readonly issue: ParseIssue
) }
Since v3.10.0
_tag (property)
Signature
readonly _tag: "Pointer"
Since v3.10.0
Refinement (class)
Error that occurs when a refinement has an error.
Signature
declare class Refinement { constructor(
readonly ast: AST.Refinement,
readonly actual: unknown,
readonly kind: "From" | "Predicate",
readonly issue: ParseIssue
) }
Since v3.10.0
_tag (property)
Signature
readonly _tag: "Refinement"
Since v3.10.0
SingleOrNonEmpty (type alias)
Signature
type SingleOrNonEmpty<A> = A | Arr.NonEmptyReadonlyArray<A>
Since v3.10.0
Transformation (class)
Error that occurs when a transformation has an error.
Signature
declare class Transformation { constructor(
readonly ast: AST.Transformation,
readonly actual: unknown,
readonly kind: "Encoded" | "Transformation" | "Type",
readonly issue: ParseIssue
) }
Since v3.10.0
_tag (property)
Signature
readonly _tag: "Transformation"
Since v3.10.0
Type (class)
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(
readonly ast: AST.AST,
readonly actual: unknown,
readonly message?: string
) }
Since v3.10.0
_tag (property)
Signature
readonly _tag: "Type"
Since v3.10.0
Unexpected (class)
Error that occurs when an unexpected key or index is present.
Signature
declare class Unexpected { constructor(
readonly actual: unknown,
/**
* @since 3.10.0
*/
readonly message?: string
) }
Since v3.10.0
_tag (property)
Signature
readonly _tag: "Unexpected"
Since v3.10.0
optimisation
eitherOrUndefined
Signature
declare const eitherOrUndefined: <A, E, R>(self: Effect.Effect<A, E, R>) => Either.Either<A, E> | undefined
Since v3.10.0
flatMap
Signature
declare const flatMap: {
<A, B, E1, R1>(
f: (a: A) => Effect.Effect<B, E1, R1>
): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, E1 | E, R1 | R>
<A, E, R, B, E1, R1>(
self: Effect.Effect<A, E, R>,
f: (a: A) => Effect.Effect<B, E1, R1>
): Effect.Effect<B, E | E1, R | R1>
}
Since v3.10.0
map
Signature
declare const map: {
<A, B>(f: (a: A) => B): <E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<B, E, R>
<A, E, R, B>(self: Effect.Effect<A, E, R>, f: (a: A) => B): Effect.Effect<B, E, R>
}
Since v3.10.0
mapBoth
Signature
declare const mapBoth: {
<E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2
readonly onSuccess: (a: A) => A2
}): <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A2, E2, R>
<A, E, R, E2, A2>(
self: Effect.Effect<A, E, R>,
options: { readonly onFailure: (e: E) => E2; readonly onSuccess: (a: A) => A2 }
): Effect.Effect<A2, E2, R>
}
Since v3.10.0
mapError
Signature
declare const mapError: {
<E, E2>(f: (e: E) => E2): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E2, R>
<A, E, R, E2>(self: Effect.Effect<A, E, R>, f: (e: E) => E2): Effect.Effect<A, E2, R>
}
Since v3.10.0
orElse
Signature
declare const orElse: {
<E, A2, E2, R2>(
f: (e: E) => Effect.Effect<A2, E2, R2>
): <A, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A2 | A, E2, R2 | R>
<A, E, R, A2, E2, R2>(
self: Effect.Effect<A, E, R>,
f: (e: E) => Effect.Effect<A2, E2, R2>
): Effect.Effect<A2 | A, E2, R2 | R>
}
Since v3.10.0
type id
ParseErrorTypeId
Signature
declare const ParseErrorTypeId: unique symbol
Since v3.10.0
ParseErrorTypeId (type alias)
Signature
type ParseErrorTypeId = typeof ParseErrorTypeId
Since v3.10.0
utils
DeclarationDecodeUnknown (type alias)
Signature
type DeclarationDecodeUnknown<Out, R> = (
u: unknown,
options: AST.ParseOptions,
ast: AST.Declaration
) => Effect.Effect<Out, ParseIssue, R>
Since v3.10.0
DecodeUnknown (type alias)
Signature
type DecodeUnknown<Out, R> = (u: unknown, options?: AST.ParseOptions) => Effect.Effect<Out, ParseIssue, R>
Since v3.10.0
ParseError (class)
Signature
declare class ParseError
Since v3.10.0
toString (method)
Signature
declare const toString: () => string
Since v3.10.0
toJSON (method)
Signature
declare const toJSON: () => { _id: string; message: string }
Since v3.10.0
[Inspectable.NodeInspectSymbol] (method)
Signature
declare const [Inspectable.NodeInspectSymbol]: () => { _id: string; message: string; }
Since v3.10.0
[ParseErrorTypeId] (property)
Signature
readonly [ParseErrorTypeId]: symbol
Since v3.10.0
isParseError
Signature
declare const isParseError: (u: unknown) => u is ParseError
Since v3.10.0
validation
asserts
By default the option exact
is set to true
.
Throws
ParseError
Signature
declare const asserts: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => asserts u is A
Since v3.10.0
is
By default the option exact
is set to true
.
Signature
declare const is: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions | number) => u is A
Since v3.10.0
validate
Signature
declare const validate: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions
) => (a: unknown, overrideOptions?: AST.ParseOptions) => Effect.Effect<A, ParseIssue, R>
Since v3.10.0
validateEither
Signature
declare const validateEither: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Either.Either<A, ParseIssue>
Since v3.10.0
validateOption
Signature
declare const validateOption: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Option.Option<A>
Since v3.10.0
validatePromise
Signature
declare const validatePromise: <A, I>(
schema: Schema.Schema<A, I, never>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Promise<A>
Since v3.10.0
validateSync
Throws
ParseError
Signature
declare const validateSync: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => A
Since v3.10.0