> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Hex.assert

:::info
`Hex.assert` is a re-export of ox's [`Hex.assert`](https://oxlib.sh/api/Hex/assert). Refer to the ox documentation for the full reference.
:::

Asserts if the given value is [`Hex.Hex`](/docs/utilities/hex/types#hex).

## Imports

```ts
import { Hex } from 'viem/utils'
```

## Examples

```ts twoslash
// @noErrors
import { Hex } from 'viem/utils'

Hex.assert('abc')
// @error: InvalidHexValueTypeError:
// @error: Value `"abc"` of type `string` is an invalid hex type.
// @error: Hex types must be represented as `"0x\${string}"`.
```

## Definition

```ts
function assert(
  value: unknown,
  options?: assert.Options,
): asserts value is Hex
```

## Parameters

### value

* **Type:** `unknown`

The value to assert.

### options

* **Type:** `assert.Options`
* **Optional**

Options.

#### options.strict

* **Type:** `boolean`
* **Optional**

Checks if the [`Hex.Hex`](/docs/utilities/hex/types#hex) value contains invalid hexadecimal characters.
