Skip to main content Link Search Menu Expand Document (external link)

ParseResult overview

Added in v1.0.0


Table of contents


constructors

fail

Signature

export declare const fail: (issue: ParseIssue) => Either.Either<never, ParseIssue>

Added in v1.0.0

fromOption

Signature

export 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>
}

Added in v1.0.0

missing

Signature

export declare const missing: Missing

Added in v1.0.0

parseError

Signature

export declare const parseError: (issue: ParseIssue) => ParseError

Added in v1.0.0

succeed

Signature

export declare const succeed: <A>(a: A) => Either.Either<A, ParseIssue>

Added in v1.0.0

try

Signature

export declare const try: <A>(options: { try: LazyArg<A>; catch: (e: unknown) => ParseIssue; }) => Either.Either<A, ParseIssue>

Added in v1.0.0

decoding

decode

Signature

export 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>

Added in v1.0.0

decodeEither

Signature

export declare const decodeEither: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (i: I, overrideOptions?: AST.ParseOptions) => Either.Either<A, ParseIssue>

Added in v1.0.0

decodeOption

Signature

export declare const decodeOption: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (i: I, overrideOptions?: AST.ParseOptions) => Option.Option<A>

Added in v1.0.0

decodePromise

Signature

export declare const decodePromise: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (i: I, overrideOptions?: AST.ParseOptions) => Promise<A>

Added in v1.0.0

decodeSync

Signature

export declare const decodeSync: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (i: I, overrideOptions?: AST.ParseOptions) => A

Added in v1.0.0

decodeUnknown

Signature

export 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>

Added in v1.0.0

decodeUnknownEither

Signature

export declare const decodeUnknownEither: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Either.Either<A, ParseIssue>

Added in v1.0.0

decodeUnknownOption

Signature

export declare const decodeUnknownOption: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Option.Option<A>

Added in v1.0.0

decodeUnknownPromise

Signature

export declare const decodeUnknownPromise: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Promise<A>

Added in v1.0.0

decodeUnknownSync

Signature

export declare const decodeUnknownSync: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => A

Added in v1.0.0

encoding

encode

Signature

export 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>

Added in v1.0.0

encodeEither

Signature

export declare const encodeEither: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (a: A, overrideOptions?: AST.ParseOptions) => Either.Either<I, ParseIssue>

Added in v1.0.0

encodeOption

Signature

export declare const encodeOption: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (input: A, overrideOptions?: AST.ParseOptions) => Option.Option<I>

Added in v1.0.0

encodePromise

Signature

export declare const encodePromise: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (a: A, overrideOptions?: AST.ParseOptions) => Promise<I>

Added in v1.0.0

encodeSync

Signature

export declare const encodeSync: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (a: A, overrideOptions?: AST.ParseOptions) => I

Added in v1.0.0

encodeUnknown

Signature

export 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>

Added in v1.0.0

encodeUnknownEither

Signature

export declare const encodeUnknownEither: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Either.Either<I, ParseIssue>

Added in v1.0.0

encodeUnknownOption

Signature

export declare const encodeUnknownOption: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Option.Option<I>

Added in v1.0.0

encodeUnknownPromise

Signature

export declare const encodeUnknownPromise: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Promise<I>

Added in v1.0.0

encodeUnknownSync

Signature

export declare const encodeUnknownSync: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => I

Added in v1.0.0

model

Declaration (class)

Error that occurs when a declaration has an error.

Signature

export declare class Declaration { constructor(readonly ast: AST.Declaration, readonly actual: unknown, readonly error: ParseIssue) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Declaration"

Added in v1.0.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

export declare class Forbidden { constructor(readonly ast: AST.AST, readonly actual: unknown, message?: string) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Forbidden"

Added in v1.0.0

message (property)

Signature

readonly message: Option.Option<string>

Added in v1.0.0

Index (class)

The Index error indicates that there was an error at a specific index in an array or tuple.

Signature

export declare class Index { constructor(readonly index: number, readonly error: ParseIssue | Missing | Unexpected) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Index"

Added in v1.0.0

Key (class)

The Key variant of the ParseIssue type represents an error that occurs when a key in a type literal or record is invalid.

Signature

export declare class Key { constructor(readonly key: PropertyKey, readonly error: ParseIssue | Missing | Unexpected) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Key"

Added in v1.0.0

Member (class)

Error that occurs when a member in a union has an error.

Signature

export declare class Member { constructor(readonly ast: AST.AST, readonly error: ParseIssue) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Member"

Added in v1.0.0

Missing (class)

Error that occurs when a required key or index is missing.

Signature

export declare class Missing

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Missing"

Added in v1.0.0

ParseIssue (type alias)

ParseIssue is a type that represents the different types of errors that can occur when decoding/encoding a value.

Signature

export type ParseIssue = Declaration | Refinement | TupleType | TypeLiteral | Union | Transformation | Type | Forbidden

Added in v1.0.0

Refinement (class)

Error that occurs when a refinement has an error.

Signature

export declare class Refinement { constructor(
    readonly ast: AST.Refinement<AST.AST>,
    readonly actual: unknown,
    readonly kind: "From" | "Predicate",
    readonly error: ParseIssue
  ) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Refinement"

Added in v1.0.0

Transformation (class)

Error that occurs when a transformation has an error.

Signature

export declare class Transformation { constructor(
    readonly ast: AST.Transformation,
    readonly actual: unknown,
    readonly kind: "Encoded" | "Transformation" | "Type",
    readonly error: ParseIssue
  ) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Transformation"

Added in v1.0.0

TupleType (class)

Error that occurs when an array or tuple has an error.

Signature

export declare class TupleType { constructor(
    readonly ast: AST.TupleType,
    readonly actual: unknown,
    readonly errors: Arr.NonEmptyReadonlyArray<Index>,
    readonly output: ReadonlyArray<unknown> = []
  ) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "TupleType"

Added in v1.0.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

export declare class Type { constructor(readonly ast: AST.AST, readonly actual: unknown, message?: string) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Type"

Added in v1.0.0

message (property)

Signature

readonly message: Option.Option<string>

Added in v1.0.0

TypeLiteral (class)

Error that occurs when a type literal or record has an error.

Signature

export declare class TypeLiteral { constructor(
    readonly ast: AST.TypeLiteral,
    readonly actual: unknown,
    readonly errors: Arr.NonEmptyReadonlyArray<Key>,
    readonly output: { readonly [x: string]: unknown } = {}
  ) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "TypeLiteral"

Added in v1.0.0

Unexpected (class)

Error that occurs when an unexpected key or index is present.

Signature

export declare class Unexpected { constructor(readonly ast: AST.AST) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Unexpected"

Added in v1.0.0

Union (class)

Error that occurs when a union has an error.

Signature

export declare class Union { constructor(
    readonly ast: AST.Union,
    readonly actual: unknown,
    readonly errors: Arr.NonEmptyReadonlyArray<Type | TypeLiteral | Member>
  ) }

Added in v1.0.0

_tag (property)

Signature

readonly _tag: "Union"

Added in v1.0.0

optimisation

eitherOrUndefined

Signature

export declare const eitherOrUndefined: <A, E, R>(self: Effect.Effect<A, E, R>) => any

Added in v1.0.0

flatMap

Signature

export 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>
}

Added in v1.0.0

map

Signature

export 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>
}

Added in v1.0.0

mapBoth

Signature

export 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>
}

Added in v1.0.0

mapError

Signature

export 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>
}

Added in v1.0.0

orElse

Signature

export 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<A | A2, E2, R | R2>
}

Added in v1.0.0

utils

DeclarationDecodeUnknown (type alias)

Signature

export type DeclarationDecodeUnknown<Out, R> = (
  u: unknown,
  options: AST.ParseOptions,
  ast: AST.Declaration
) => Effect.Effect<Out, ParseIssue, R>

Added in v1.0.0

DecodeUnknown (type alias)

Signature

export type DecodeUnknown<Out, R> = (u: unknown, options?: AST.ParseOptions) => Effect.Effect<Out, ParseIssue, R>

Added in v1.0.0

ParseError (class)

Signature

export declare class ParseError

Added in v1.0.0

toString (method)

Signature

toString()

Added in v1.0.0

toJSON (method)

Signature

toJSON()

Added in v1.0.0

[Inspectable.NodeInspectSymbol] (method)

Signature

;[Inspectable.NodeInspectSymbol]()

Added in v1.0.0

validation

asserts

Signature

export declare const asserts: <A, I, R>(
  schema: Schema.Schema<A, I, R>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => asserts u is A

Added in v1.0.0

is

Signature

export declare const is: <A, I, R>(
  schema: Schema.Schema<A, I, R>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => u is A

Added in v1.0.0

validate

Signature

export 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>

Added in v1.0.0

validateEither

Signature

export declare const validateEither: <A, I, R>(
  schema: Schema.Schema<A, I, R>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Either.Either<A, ParseIssue>

Added in v1.0.0

validateOption

Signature

export declare const validateOption: <A, I, R>(
  schema: Schema.Schema<A, I, R>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Option.Option<A>

Added in v1.0.0

validatePromise

Signature

export declare const validatePromise: <A, I>(
  schema: Schema.Schema<A, I, never>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => Promise<A>

Added in v1.0.0

validateSync

Signature

export declare const validateSync: <A, I, R>(
  schema: Schema.Schema<A, I, R>,
  options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions) => A

Added in v1.0.0