Skip to content

Commit

Permalink
More fixes around discriminatedUnion, improve withError
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGalays committed Jul 20, 2021
1 parent 3942f88 commit 4e91935
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 81 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ const bag = union(null, 'hello', true, 33)
### discriminatedUnion

Although you could also use `union` for your discriminated unions, `discriminatedUnion` is faster and has better error messages for that special case. It will also catch common typos at the type level.
Note that `discriminatedUnion` only works with `object` and `intersection` (of objects) validators. Also, the discriminating property must be either a `literal` or `union` of primitives.

```ts
import {discriminatedUnion, literal, string} from 'idonttrustlikethat'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "idonttrustlikethat",
"version": "2.0.4",
"version": "2.0.5",
"sideEffects": false,
"description": "Validation for TypeScript",
"license": "MIT",
Expand Down
Loading

0 comments on commit 4e91935

Please sign in to comment.