Skip to content

InfallibleParser()<T>

ts
type InfallibleParser<T>: (data) => ParseSuccess<T>;

A parser that always succeeds

Type Parameters

Type Parameter
T

Parameters

ParameterType
dataunknown

Returns

ParseSuccess<T>


OptionalParser()<T>

ts
type OptionalParser<T>: (data) => ParseResult<T | undefined | OmitProperty>;

Special parser to check optional values

Type Parameters

Type Parameter
T

Parameters

ParameterType
dataunknown

Returns

ParseResult<T | undefined | OmitProperty>


ParseFailure

ts
type ParseFailure: {
  error: string;
  path: ParseFailurePathSegment[];
  tag: "failure";
};

The parsing failed.

Type declaration

error

ts
error: string;

path

ts
path: ParseFailurePathSegment[];

tag

ts
tag: "failure";

ParseFailurePathSegment

ts
type ParseFailurePathSegment: {
  key: string;
  tag: "object";
 } | {
  index: number;
  tag: "array";
};

Parser()<T>

ts
type Parser<T>: (data) => ParseResult<T>;

Type Parameters

Type Parameter
T

Parameters

ParameterType
dataunknown

Returns

ParseResult<T>


ParseResult<T>

ts
type ParseResult<T>: ParseSuccess<T> | ParseFailure;

Type Parameters

Type Parameter
T

ParseSuccess<T>

ts
type ParseSuccess<T>: {
  tag: "success";
  value: T;
};

The data adheres to the schema. The value is equal to the parsed data

Type Parameters

Type Parameter
T

Type declaration

tag

ts
tag: "success";

value

ts
value: T;

RequiredParser()<T>

ts
type RequiredParser<T>: (data) => ParseResult<Exclude<T, OmitProperty>>;

A parser that does not represent an optional property.

Type Parameters

Type Parameter
T

Parameters

ParameterType
dataunknown

Returns

ParseResult<Exclude<T, OmitProperty>>


UnsuccessfulParser()

ts
type UnsuccessfulParser: (data) => ParseFailure;

A parser that always fails

Parameters

ParameterType
dataunknown

Returns

ParseFailure


failure()

ts
function failure(error): ParseFailure

Parameters

ParameterType
errorstring

Returns

ParseFailure


isFailure()

ts
function isFailure<T>(result): result is ParseFailure

Check if the result is a failure

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
resultParseResult<T>

Returns

result is ParseFailure


isSuccess()

ts
function isSuccess<T>(result): result is ParseSuccess<T>

Check if the result is a success

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
resultParseResult<T>

Returns

result is ParseSuccess<T>


propagateFailure()

ts
function propagateFailure(failureRes, pathSegment): ParseFailure

Parameters

ParameterType
failureResParseFailure
pathSegmentParseFailurePathSegment

Returns

ParseFailure


success()

ts
function success<T>(value): ParseSuccess<T>

Type Parameters

Type Parameter
T

Parameters

ParameterType
valueT

Returns

ParseSuccess<T>