Adds custom assertion message example to README
This commit is contained in:
parent
d9619cdc01
commit
7a397c996f
1 changed files with 9 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue