JSON-Schema compatible validator used internally by web3.js v4 for validating addresses, bytes, numbers, and other Ethereum data types. Current version 2.0.6 (stable), part of the web3.js v4 monorepo with a release cadence aligned to web3.js releases. It wraps ajv and adds Ethereum-specific validators. Key differentiator: integrates directly with web3.js 4.x for automatic input validation, but can be used standalone. Compared to @ethersproject/address or @ethereumjs/util, it provides a full JSON Schema validator with custom keywords (e.g., 'bytes', 'address') and supports Ethereum ABI types.
npm install web3-validatorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Web3Validator instance and uses it to validate an Ethereum address and a hex string against JSON Schema with custom formats.
Use import syntax or dynamic import('web3-validator').Import { isAddress } from 'web3-validator'.Use validator.validate(schema, data) instead of validator.validate(data).
Always use 'format': 'address' for Ethereum address validation.
Set environment polyfills or use a bundler plugin to handle fetch.
Change to 'import { Web3Validator } from 'web3-validator'.Run 'npm install web3-validator' and ensure Node >=14.
Ensure the address is a 40-character hex string prefixed with '0x' and checksummed if using EIP-55.