Skip to content

Commit

Permalink
fix: Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gillchristian committed Jun 25, 2020
1 parent c75417a commit 2816c9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# io-ts-reporters

[Error reporters](https://github.com/gcanti/io-ts#error-reporters) for [io-ts](https://github.com/gcanti/io-ts).
[Error reporters](https://github.com/gcanti/io-ts#error-reporters) for
[io-ts](https://github.com/gcanti/io-ts).

Currently this package only includes one reporter. The output is an array of strings in the format of:
Currently this package only includes one reporter. The output is an array of
strings in the format of:

```
Expecting ${expectedType} at ${path} but instead got: ${expectedType}
Expand Down Expand Up @@ -30,7 +32,6 @@ yarn add io-ts-reporters
```ts
import * as t from 'io-ts';
import reporter from 'io-ts-reporters';
import * as E from 'fp-ts/lib/Either';

const User = t.interface({ name: t.string });

Expand All @@ -54,7 +55,9 @@ import { pipe } from 'fp-ts/lib/pipeable';

const User = t.interface({ name: t.string });

pipe({ nam: 'Jane' }, User.decode, E.mapLeft(formatValidationErrors));
const result = User.decode({ nam: 'Jane' }); // Either<t.Errors, User>

E.mapLeft(formatValidationErrors)(result); // Either<string[], User>
```

For more examples see [the tests](./tests/index.test.ts).
Expand Down
11 changes: 7 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ nav_order: 1

# io-ts-reporters

[Error reporters](https://github.com/gcanti/io-ts#error-reporters) for [io-ts](https://github.com/gcanti/io-ts).
[Error reporters](https://github.com/gcanti/io-ts#error-reporters) for
[io-ts](https://github.com/gcanti/io-ts).

Currently this package only includes one reporter. The output is an array of strings in the format of:
Currently this package only includes one reporter. The output is an array of
strings in the format of:

```
Expecting ${expectedType} at ${path} but instead got: ${expectedType}
Expand All @@ -29,7 +31,6 @@ at ${path} but instead got: ${actualValue}
```ts
import * as t from 'io-ts';
import reporter from 'io-ts-reporters';
import * as E from 'fp-ts/lib/Either';

const User = t.interface({ name: t.string });

Expand All @@ -53,7 +54,9 @@ import { pipe } from 'fp-ts/lib/pipeable';

const User = t.interface({ name: t.string });

pipe({ nam: 'Jane' }, User.decode, E.mapLeft(formatValidationErrors));
const result = User.decode({ nam: 'Jane' }); // Either<t.Errors, User>

E.mapLeft(formatValidationErrors)(result); // Either<string[], User>
```

For more examples see [the tests](./tests/index.test.ts).
Expand Down

0 comments on commit 2816c9f

Please sign in to comment.