[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Assert](https://evolu.dev/docs/api-reference/common/Assert) › assert

```ts
const assert: (condition: unknown, message: string) => asserts condition;
```

Defined in: [packages/common/src/Assert.ts:43](https://github.com/evoluhq/evolu/blob/037c390af081e9944d616ff298a729515c5c5ab7/packages/common/src/Assert.ts#L43)

Ensures a condition is true, throwing an error with the provided message if
not.

Prevents invalid states from propagating through the system by halting
execution when a condition fails, improving reliability and debuggability.

Do not use this instead of [Type](https://evolu.dev/docs/api-reference/common/Type/interfaces/Type). Assertions are intended when a
condition is logically guaranteed to be true but TypeScript cannot prove it,
or for catching and signaling developer mistakes eagerly.

### Example

```ts

assert(true, "Expected true.");
const result = trySync(() => assert(false, "Expected true."));
assertErr(result);
assert(result.error instanceof Error, "Expected an Error.");
assertEqual(result.error.message, "Expected true.");
```