Skip to content

Commit

Permalink
Adds custom assertion message example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
marlun78 committed Apr 22, 2024
1 parent d9619cd commit 7a397c9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ assert.string(2);
//=> Error: Expected value which is `string`, received value of type `number`.
```

Most assertions also support an optional custom error message.

```js
import {assert} from '@sindresorhus/is';

assert.nonEmptyString(process.env.API_URL, 'API_URL env variable is required.');
//=> Error: API_URL env variable is required.
```

And with TypeScript:

```ts
Expand Down

0 comments on commit 7a397c9

Please sign in to comment.