/** * **This module is experimental** * * Experimental features are published in order to get early feedback from the community, see these tracking * [issues](https://github.com/gcanti/io-ts/issues?q=label%3Av2.2+) for further discussions and enhancements. * * A feature tagged as _Experimental_ is in a high state of flux, you're at risk of it changing without notice. * * @since 2.2.7 */ import { Alt2 } from 'fp-ts/lib/Alt' import { Category2 } from 'fp-ts/lib/Category' import * as E from 'fp-ts/lib/Either' import { Refinement } from 'fp-ts/lib/function' import { Functor2 } from 'fp-ts/lib/Functor' import * as DE from './DecodeError' import * as FS from './FreeSemigroup' import * as G from './Guard' import * as K from './Kleisli' import * as S from './Schemable' /** * @category model * @since 2.2.8 */ export interface Decoder extends K.Kleisli {} /** * @category DecodeError * @since 2.2.7 */ export declare type DecodeError = FS.FreeSemigroup> /** * @category DecodeError * @since 2.2.7 */ export declare const error: (actual: unknown, message: string) => DecodeError /** * @category DecodeError * @since 2.2.7 */ export declare const success: (a: A) => E.Either /** * @category DecodeError * @since 2.2.7 */ export declare const failure: (actual: unknown, message: string) => E.Either /** * @category constructors * @since 2.2.8 */ export declare const fromRefinement: (refinement: Refinement, expected: string) => Decoder /** * @category constructors * @since 2.2.8 */ export declare const fromGuard: (guard: G.Guard, expected: string) => Decoder /** * @category constructors * @since 2.2.7 */ export declare const literal: ], L extends S.Literal = S.Literal>( ...values: A ) => Decoder /** * @category primitives * @since 2.2.7 */ export declare const string: Decoder /** * @category primitives * @since 2.2.7 */ export declare const number: Decoder /** * @category primitives * @since 2.2.7 */ export declare const boolean: Decoder /** * @category primitives * @since 2.2.7 */ export declare const UnknownArray: Decoder> /** * @category primitives * @since 2.2.7 */ export declare const UnknownRecord: Decoder> /** * @category combinators * @since 2.2.7 */ export declare const mapLeftWithInput: ( f: (input: I, e: DecodeError) => DecodeError ) => (decoder: Decoder) => Decoder /** * @category combinators * @since 2.2.9 */ export declare const withMessage: ( message: (input: I, e: DecodeError) => string ) => (decoder: Decoder) => Decoder /** * @category combinators * @since 2.2.7 */ export declare const refine: ( refinement: Refinement, id: string ) => (from: Decoder) => Decoder /** * @category combinators * @since 2.2.7 */ export declare const parse: ( parser: (a: A) => E.Either ) => (from: Decoder) => Decoder /** * @category combinators * @since 2.2.7 */ export declare const nullable: (or: Decoder) => Decoder /** * @category combinators * @since 2.2.15 */ export declare const fromStruct:

>>( properties: P ) => Decoder<{ [K in keyof P]: K.InputOf<'Either', P[K]> }, { [K_1 in keyof P]: K.TypeOf<'Either', P[K_1]> }> /** * Use `fromStruct` instead. * * @category combinators * @since 2.2.8 * @deprecated */ export declare const fromType:

>>( properties: P ) => Decoder< Partial<{ [K in keyof P]: K.InputOf<'Either', P[K]> }>, Partial<{ [K_1 in keyof P]: K.TypeOf<'Either', P[K_1]> }> > /** * @category combinators * @since 2.2.7 */ export declare const partial: ( properties: { [K in keyof A]: Decoder } ) => Decoder> /** * @category combinators * @since 2.2.8 */ export declare const fromArray: (item: Decoder) => Decoder /** * @category combinators * @since 2.2.7 */ export declare const array: (item: Decoder) => Decoder /** * @category combinators * @since 2.2.8 */ export declare const fromRecord: (codomain: Decoder) => Decoder, Record> /** * @category combinators * @since 2.2.7 */ export declare const record: (codomain: Decoder) => Decoder> /** * @category combinators * @since 2.2.8 */ export declare const fromTuple: []>( ...components: C ) => Decoder<{ [K in keyof C]: K.InputOf<'Either', C[K]> }, { [K_1 in keyof C]: K.TypeOf<'Either', C[K_1]> }> /** * @category combinators * @since 2.2.7 */ export declare const tuple: ( ...components: { [K in keyof A]: Decoder } ) => Decoder /** * @category combinators * @since 2.2.7 */ export declare const union: , ...Array>]>( ...members: MS ) => Decoder, TypeOf> /** * @category combinators * @since 2.2.7 */ export declare const intersect: ( right: Decoder ) => (left: Decoder) => Decoder /** * @category combinators * @since 2.2.8 */ export declare const fromSum: ( tag: T ) => >>( members: MS ) => Decoder, K.TypeOf<'Either', MS[keyof MS]>> /** * @category combinators * @since 2.2.7 */ export declare const sum: ( tag: T ) => (members: { [K in keyof A]: Decoder> }) => Decoder /** * @category combinators * @since 2.2.7 */ export declare const lazy: (id: string, f: () => Decoder) => Decoder /** * @category combinators * @since 2.2.15 */ export declare const readonly: (decoder: Decoder) => Decoder> /** * @category Functor * @since 2.2.7 */ export declare const map: (f: (a: A) => B) => (fa: Decoder) => Decoder /** * @category Alt * @since 2.2.7 */ export declare const alt: (that: () => Decoder) => (me: Decoder) => Decoder /** * @category Semigroupoid * @since 2.2.8 */ export declare const compose: (to: Decoder) => (from: Decoder) => Decoder /** * @category Category * @since 2.2.8 */ export declare const id: () => Decoder /** * @category instances * @since 2.2.7 */ export declare const URI = 'io-ts/Decoder' /** * @category instances * @since 2.2.7 */ export declare type URI = typeof URI declare module 'fp-ts/lib/HKT' { interface URItoKind2 { readonly [URI]: Decoder } } /** * @category instances * @since 2.2.8 */ export declare const Functor: Functor2 /** * @category instances * @since 2.2.8 */ export declare const Alt: Alt2 /** * @category instances * @since 2.2.8 */ export declare const Category: Category2 /** * @category instances * @since 2.2.8 */ export declare const Schemable: S.Schemable2C /** * @category instances * @since 2.2.8 */ export declare const WithUnknownContainers: S.WithUnknownContainers2C /** * @category instances * @since 2.2.8 */ export declare const WithUnion: S.WithUnion2C /** * @category instances * @since 2.2.8 */ export declare const WithRefine: S.WithRefine2C /** * @since 2.2.8 */ export declare type InputOf = K.InputOf /** * @since 2.2.7 */ export declare type TypeOf = K.TypeOf /** * @since 2.2.7 */ export declare const draw: (e: DecodeError) => string

>>( properties: P ) => Decoder<{ [K in keyof P]: K.InputOf<'Either', P[K]> }, { [K_1 in keyof P]: K.TypeOf<'Either', P[K_1]> }> /** * @category combinators * @since 2.2.15 */ export declare const struct: ( properties: { [K in keyof A]: Decoder } ) => Decoder /** * Use `struct` instead. * * @category combinators * @since 2.2.7 * @deprecated */ export declare const type: ( properties: { [K in keyof A]: Decoder } ) => Decoder /** * @category combinators * @since 2.2.8 */ export declare const fromPartial: