1 | /**
|
2 | * @since 0.5.12
|
3 | */
|
4 | import * as t from 'io-ts'
|
5 | /**
|
6 | * Returns a clone of the given codec which uses the given `encode` function
|
7 | *
|
8 | * @example
|
9 | * import { withEncode } from 'io-ts-types/lib/withEncode'
|
10 | * import * as t from 'io-ts'
|
11 | * import { PathReporter } from 'io-ts/lib/PathReporter'
|
12 | * import { right } from 'fp-ts/lib/Either'
|
13 | *
|
14 | * const T = withEncode(t.number, String)
|
15 | *
|
16 | * assert.deepStrictEqual(T.decode(1), right(1))
|
17 | * assert.deepStrictEqual(T.encode(1), '1')
|
18 | * assert.deepStrictEqual(PathReporter.report(T.decode('str')), ['Invalid value "str" supplied to : number'])
|
19 | *
|
20 | * @since 0.5.12
|
21 | */
|
22 | export declare function withEncode<A, O, I, P>(
|
23 | codec: t.Type<A, O, I>,
|
24 | encode: (a: A) => P,
|
25 | name?: string
|
26 | ): t.Type<A, P, I>
|
27 |
|
\ | No newline at end of file |