ParseResult overview
Added in v0.67.0
Table of contents
- constructors
- decoding
- encoding
- guards
- model
- optimisation
- type id
- utils
- validation
constructors
fail
Signature
export declare const fail: (issue: ParseIssue) => Either.Either<never, ParseIssue>
Added in v0.67.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 v0.67.0
parseError
Signature
export declare const parseError: (issue: ParseIssue) => ParseError
Added in v0.67.0
succeed
Signature
export declare const succeed: <A>(a: A) => Either.Either<A, ParseIssue>
Added in v0.67.0
try
Signature
export declare const try: <A>(options: { try: LazyArg<A>; catch: (e: unknown) => ParseIssue; }) => Either.Either<A, ParseIssue>
Added in v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.0
guards
isComposite
Returns true
if the value is a Composite
.
Signature
export declare const isComposite: (u: unknown) => u is Composite
Added in v0.68.0
model
Composite (class)
Error that contains multiple issues.
Signature
export declare class Composite { constructor(
readonly ast: AST.AST,
readonly actual: unknown,
readonly issues: SingleOrNonEmpty<ParseIssue>,
readonly output?: unknown
) }
Added in v0.68.0
_tag (property)
Signature
readonly _tag: "Composite"
Added in v0.68.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,
readonly message?: string
) }
Added in v0.67.0
_tag (property)
Signature
readonly _tag: "Forbidden"
Added in v0.67.0
Missing (class)
Error that occurs when a required key or index is missing.
Signature
export declare class Missing { constructor(
/**
* @since 0.68.0
*/
readonly ast: AST.Type,
/**
* @since 0.68.0
*/
readonly message?: string
) }
Added in v0.67.0
_tag (property)
Signature
readonly _tag: "Missing"
Added in v0.67.0
actual (property)
Signature
readonly actual: undefined
Added in v0.68.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 =
// leaf
| Type
| Missing
| Unexpected
| Forbidden
// composite
| Pointer
| Refinement
| Transformation
| Composite
Added in v0.67.0
Path (type alias)
Signature
export type Path = SingleOrNonEmpty<PropertyKey>
Added in v0.68.0
Pointer (class)
Signature
export declare class Pointer { constructor(
readonly path: Path,
readonly actual: unknown,
readonly issue: ParseIssue
) }
Added in v0.68.0
_tag (property)
Signature
readonly _tag: "Pointer"
Added in v0.68.0
Refinement (class)
Error that occurs when a refinement has an error.
Signature
export declare class Refinement { constructor(
readonly ast: AST.Refinement,
readonly actual: unknown,
readonly kind: "From" | "Predicate",
readonly issue: ParseIssue
) }
Added in v0.67.0
_tag (property)
Signature
readonly _tag: "Refinement"
Added in v0.67.0
SingleOrNonEmpty (type alias)
Signature
export type SingleOrNonEmpty<A> = A | array_.NonEmptyReadonlyArray<A>
Added in v0.68.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 issue: ParseIssue
) }
Added in v0.67.0
_tag (property)
Signature
readonly _tag: "Transformation"
Added in v0.67.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,
readonly message?: string
) }
Added in v0.67.0
_tag (property)
Signature
readonly _tag: "Type"
Added in v0.67.0
Unexpected (class)
Error that occurs when an unexpected key or index is present.
Signature
export declare class Unexpected { constructor(
readonly actual: unknown,
/**
* @since 0.68.0
*/
readonly message?: string
) }
Added in v0.67.0
_tag (property)
Signature
readonly _tag: "Unexpected"
Added in v0.67.0
optimisation
eitherOrUndefined
Signature
export declare const eitherOrUndefined: <A, E, R>(self: Effect.Effect<A, E, R>) => Either.Either<A, E> | undefined
Added in v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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<A2 | A, E2, R2 | R>
}
Added in v0.67.0
type id
ParseErrorTypeId
Signature
export declare const ParseErrorTypeId: typeof ParseErrorTypeId
Added in v0.68.0
ParseErrorTypeId (type alias)
Signature
export type ParseErrorTypeId = typeof ParseErrorTypeId
Added in v0.68.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 v0.67.0
DecodeUnknown (type alias)
Signature
export type DecodeUnknown<Out, R> = (u: unknown, options?: AST.ParseOptions) => Effect.Effect<Out, ParseIssue, R>
Added in v0.67.0
ParseError (class)
Signature
export declare class ParseError
Added in v0.67.0
toString (method)
Signature
toString()
Added in v0.67.0
toJSON (method)
Signature
toJSON()
Added in v0.67.0
[Inspectable.NodeInspectSymbol] (method)
Signature
;[Inspectable.NodeInspectSymbol]()
Added in v0.67.0
[ParseErrorTypeId] (property)
Signature
readonly [ParseErrorTypeId]: symbol
Added in v0.68.0
isParseError
Signature
export declare const isParseError: (u: unknown) => u is ParseError
Added in v0.68.0
validation
asserts
By default the option exact
is set to true
.
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 v0.67.0
is
By default the option exact
is set to true
.
Signature
export declare const is: <A, I, R>(
schema: Schema.Schema<A, I, R>,
options?: AST.ParseOptions
) => (u: unknown, overrideOptions?: AST.ParseOptions | number) => u is A
Added in v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.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 v0.67.0