# @theqrl/web3-validator

> JSON-Schema compatible validator for web3

Latest version **3.0.0** (published 2026-11-16) · LGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @theqrl/web3-validator
pnpm add @theqrl/web3-validator
yarn add @theqrl/web3-validator
bun add @theqrl/web3-validator
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-11-16 |
| First published | 2023-10-26 |
| Weekly downloads | 0 |
| License | LGPL-3.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.12.0 |
| Dependencies | 4 |
| Unpacked size | 2.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | The QRL Contributors |
| Maintainers | jplomas, cyyber |

## Links

- npm: https://www.npmjs.com/package/@theqrl/web3-validator
- Repository: https://github.com/theQRL/web3.js
- Homepage: https://github.com/theQRL/web3.js#readme
- Issues: https://github.com/theQRL/web3.js/issues
- npm.io page: https://npm.io/package/@theqrl/web3-validator

## Dependencies (4)

- [zod](https://npm.io/package/zod.md) 4.6.7
- [@theqrl/web3-types](https://npm.io/package/@theqrl/web3-types.md) ^3.0.0
- [@theqrl/web3-errors](https://npm.io/package/@theqrl/web3-errors.md) ^3.0.0
- [@theqrl/qrl-cryptography](https://npm.io/package/@theqrl/qrl-cryptography.md) 0.3.3

## Recent versions

- 3.0.0 (latest) — 2026-11-16
- 0.3.2 (v0.3.2) — 2025-07-02
- 0.3.0 (v0.3.0) — 2025-02-18
- 0.2.2-dev.d92be93.1 (dev) — 2025-02-18
- 2.0.0 — 2026-11-02
- 1.0.3 — 2026-07-21
- 1.0.2 — 2026-07-16
- 1.0.1 — 2026-06-04
- 1.0.0 — 2026-05-10
- 0.5.0 — 2026-05-07
- 0.4.4 — 2026-05-07
- 0.4.3 — 2026-05-04
- 0.4.0 — 2026-04-03
- 0.3.3 — 2025-07-02
- 0.2.1 — 2023-12-19
- … 2 more at https://npm.io/package/@theqrl/web3-validator/versions

## README

# @theqrl/web3-validator

![ES Version](https://img.shields.io/badge/ES-2020-yellow)
![Node Version](https://img.shields.io/badge/node-%3E%3D20-green)
[![NPM Package](https://img.shields.io/npm/v/@theqrl/web3-validator)](https://www.npmjs.com/package/@theqrl/web3-validator)
[![Downloads](https://img.shields.io/npm/dm/@theqrl/web3-validator)](https://www.npmjs.com/package/@theqrl/web3-validator)

This is a sub-package of [@theqrl/web3.js](https://github.com/theqrl/web3.js).

`@theqrl/web3-validator` contains functions for validating objects.

## Installation

You can install the package either using [NPM](https://www.npmjs.com/package/@theqrl/web3-validator) or using [pnpm](https://pnpm.io/)

### Using NPM

```bash
npm install @theqrl/web3-validator
```

### Using pnpm

```bash
pnpm add @theqrl/web3-validator
```

## Getting Started

-   :writing_hand: If you have questions [submit an issue](https://github.com/theqrl/web3.js/issues/new) or join us on [Discord](https://theqrl.org/discord)
    ![Discord](https://img.shields.io/discord/357604137204056065.svg?label=Discord&logo=discord)

### Usage

You can use the the validator by importing as and using to validate;

```ts
import { validator } from '@theqrl/web3-validator';

// To validate and throw
validator.validate(['uint8', 'string'], [val1, val2]);

// To validate and return error
const errors = validator.validate(['uint8', 'string'], [val1, val2], { silent: true });
```

To see more examples of schema you can use to validate check [following file](./test/fixtures/abi_to_json_schema.ts).

Following qrl types are supported to validate.

| Type  | Input As                        | Description                                                                                                                                           |
| ----- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| uint  | `number`, `string`, `HexString` | Unsigned integer, all qrl compatible variants are also supported e.g. `uint8`, `uint256`. You can also use array specifiers as `uint[]` or `uint[2]` |
| int   | `number`, `string`, `HexString` | Signed integer, all qrl compatible variants are also supported e.g. `int8`, `int256`. You can also use array specifiers as `int[]` or `int[2]`       |
| bytes | `HexString`, `Uint8Array`       | Raw bytes. You can also use fixed length bytes as `bytes[2]`                                                                                          |

| string | `string` | String values |
| address | `string`, `HexString` | QRL network compatible address |
| bloom | `string`, `HexString` | Check if a given string is a Eth bloom |
| tuple | `array` | You can specify any tuple as nested arrays. e.g. `['uint', 'string']`. For a custom tuple or array tuple you can use syntax e.g. `['tuple[3]', ['uint', 'string']]` |

For the qrl compatible data values should be passed as arrays e.g. for schema `['uint', 'string']` value should be passed as `[2, 'my-string']`.

You can also pass full ABI schema for the validation. e.g.

```json
[{ "name": "owner", "type": "address" }]
```

The implementation of the validator is extension of [JSON-Schema-Draft07](https://json-schema.org/draft-07/json-schema-release-notes.html) with a custom keyword `eth`. So you can use JSON-Schema compatible schema to validate any object based data as well.

## Prerequisites

-   :gear: [NodeJS](https://nodejs.org/) (20 or newer)
-   :toolbox: [pnpm](https://pnpm.io/) and [Turbo](https://turbo.build/)

## Package.json Scripts

| Script           | Description                                        |
| ---------------- | -------------------------------------------------- |
| clean            | Uses `rimraf` to remove `dist/`                    |
| build            | Uses `tsc` to build package and dependent packages |
| lint             | Uses `eslint` to lint package                      |
| lint:fix         | Uses `eslint` to check and fix any warnings        |
| format           | Uses `prettier` to format the code                 |
| test             | Uses `jest` to run unit tests                      |
| test:integration | Uses `jest` to run tests under `/test/integration` |
| test:unit        | Uses `jest` to run tests under `/test/unit`        |

[docs]: https://docs.theqrl.org/
[repo]: https://github.com/theqrl/web3.js/tree/main/packages/web3-validator
[npm-image]: https://img.shields.io/github/package-json/v/theqrl/web3.js/main?filename=packages%2Fweb3-validator%2Fpackage.json
[npm-url]: https://npmjs.org/package/@theqrl/web3-validator
[downloads-image]: https://img.shields.io/npm/dm/@theqrl/web3-validator?label=npm%20downloads

---
_Source: https://npm.io/package/@theqrl/web3-validator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
