1 | /**
|
2 | * @since 0.4.3
|
3 | */
|
4 | import * as t from 'io-ts'
|
5 | /**
|
6 | * Returns a clone of the given codec that sets the given string as error messsage
|
7 | *
|
8 | * @example
|
9 | * import { withMessage } from 'io-ts-types/lib/withMessage'
|
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 = withMessage(t.number, () => 'Invalid number')
|
15 | *
|
16 | * assert.deepStrictEqual(T.decode(1), right(1))
|
17 | * assert.deepStrictEqual(PathReporter.report(T.decode(null)), ['Invalid number'])
|
18 | *
|
19 | * @since 0.4.3
|
20 | */
|
21 | export declare function withMessage<C extends t.Any>(codec: C, message: (i: t.InputOf<C>, c: t.Context) => string): C
|
22 |
|
\ | No newline at end of file |