import {assert, validURL} from '@muze-nl/assert'
function example(url) {
assert(url, validURL)
return fetch(url)
}This will call fails(). If any assertion fails, it will throw an error with all failed assertions. The thrown error contains the original problems and normalized structured issues on error.cause. It also logs concise one-line messages to the console, for example:
- foo: data is not a string
- bar: expected 'baz', found 'bax'
If assert is disabled--the default state--no assertions will be checked. See fails() for a list of possible assertions and issues() for path-aware issue objects.