InfallibleParser()<T>
ts
type InfallibleParser<T>: (data) => ParseSuccess<T>;
A parser that always succeeds
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
data | unknown |
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
Parameter | Type |
---|---|
data | unknown |
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
Parameter | Type |
---|---|
data | unknown |
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
Parameter | Type |
---|---|
data | unknown |
Returns
ParseResult
<Exclude
<T
, OmitProperty
>>
UnsuccessfulParser()
ts
type UnsuccessfulParser: (data) => ParseFailure;
A parser that always fails
Parameters
Parameter | Type |
---|---|
data | unknown |
Returns
failure()
ts
function failure(error): ParseFailure
Parameters
Parameter | Type |
---|---|
error | string |
Returns
isFailure()
ts
function isFailure<T>(result): result is ParseFailure
Check if the result is a failure
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
result | ParseResult <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
Parameter | Type | Description |
---|---|---|
result | ParseResult <T > |
Returns
result is ParseSuccess<T>
propagateFailure()
ts
function propagateFailure(failureRes, pathSegment): ParseFailure
Parameters
Parameter | Type |
---|---|
failureRes | ParseFailure |
pathSegment | ParseFailurePathSegment |
Returns
success()
ts
function success<T>(value): ParseSuccess<T>
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
value | T |
Returns
ParseSuccess
<T
>