{"name":"web3-validator","version":"2.0.7-dev.9086b98.0","description":"JSON-Schema compatible validator for web3","main":"./lib/commonjs/index.js","module":"./lib/esm/index.js","exports":{".":{"types":"./lib/types/index.d.ts","import":"./lib/esm/index.js","require":"./lib/commonjs/index.js"}},"repository":{"type":"git","url":"git+https://github.com/ChainSafe/web3.js.git"},"author":{"name":"ChainSafe Systems"},"license":"LGPL-3.0","engines":{"node":">=14","npm":">=6.12.0"},"scripts":{"clean":"rimraf dist && rimraf lib","prebuild":"yarn clean","build":"concurrently --kill-others-on-fail \"yarn:build:*(!check|web)\"","build:cjs":"tsc --build tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./lib/commonjs/package.json","build:esm":"tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json","build:types":"tsc --build tsconfig.types.json","build:web":"npx webpack","build:check":"node -e \"require('./lib')\"","lint":"eslint --cache --cache-strategy content --ext .ts .","lint:fix":"eslint --fix --ext .js,.ts .","format":"prettier --write '**/*'","test":"jest --config=./test/unit/jest.config.js","test:coverage:unit":"jest --config=./test/unit/jest.config.js --coverage=true --coverage-reporters=text","test:coverage:integration":"jest --config=./test/integration/jest.config.js --passWithNoTests --coverage=true --coverage-reporters=text","test:ci":"jest --coverage=true --coverage-reporters=json --verbose","test:watch":"npm test -- --watch","test:unit":"jest --config=./test/unit/jest.config.js","test:integration":"jest --config=./test/integration/jest.config.js --passWithNoTests"},"dependencies":{"ethereum-cryptography":"^2.0.0","util":"^0.12.5","web3-errors":"1.2.1-dev.9086b98.0+9086b98","web3-types":"1.6.1-dev.9086b98.0+9086b98","zod":"^3.21.4"},"devDependencies":{"@types/jest":"^28.1.6","@typescript-eslint/eslint-plugin":"^5.30.7","@typescript-eslint/parser":"^5.30.7","eslint":"^8.20.0","eslint-config-base-web3":"0.1.0","eslint-config-prettier":"^8.5.0","eslint-plugin-import":"^2.26.0","jest":"^29.7.0","jest-extended":"^3.0.1","prettier":"^2.7.1","ts-jest":"^29.1.1","typescript":"^4.7.4"},"gitHead":"9086b98f25ef7ab9de0e699c00f462dca3e66f37","types":"./lib/commonjs/index.d.ts","readme":"<p align=\"center\">\n  <img src=\"assets/logo/web3js.jpg\" width=\"500\" alt=\"web3.js\" />\n</p>\n\n# web3-validator\n\n![ES Version](https://img.shields.io/badge/ES-2020-yellow)\n![Node Version](https://img.shields.io/badge/node-14.x-green)\n[![NPM Package][npm-image]][npm-url]\n[![Downloads][downloads-image]][npm-url]\n\nThis is a sub-package of [web3.js][repo].\n\n`web3-validator` contains functions for validating objects.\n\n## Installation\n\nYou can install the package either using [NPM](https://www.npmjs.com/package/web3-validator) or using [Yarn](https://yarnpkg.com/package/web3-validator)\n\n### Using NPM\n\n```bash\nnpm install web3-validator\n```\n\n### Using Yarn\n\n```bash\nyarn add web3-validator\n```\n\n## Getting Started\n\n-   :writing_hand: If you have questions [submit an issue](https://github.com/ChainSafe/web3.js/issues/new) or join us on [Discord](https://discord.gg/yjyvFRP)\n    ![Discord](https://img.shields.io/discord/593655374469660673.svg?label=Discord&logo=discord)\n\n### Usage\n\nYou can use the validator by importing as and using to validate;\n\n```ts\nimport { validator } from 'web3-validator';\n\n// To validate and throw\nvalidator.validate(['uint8', 'string'], [val1, val2]);\n\n// To validate and return error\nconst errors = validator.validate(['uint8', 'string'], [val1, val2], { silent: true });\n```\n\nTo see more examples of schema you can use to validate check [following file](./test/fixtures/abi_to_json_schema.ts).\n\nFollowing eth types are supported to validate.\n\n| Type  | Input As                        | Description                                                                                                                                               |\n| ----- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| uint  | `number`, `string`, `HexString` | Unsigned integer, all ethereum compatible variants are also supported e.g. `uint8`, `uint256`. You can also use array specifiers as `uint[]` or `uint[2]` |\n| int   | `number`, `string`, `HexString` | Signed integer, all ethereum compatible variants are also supported e.g. `int8`, `int256`. You can also use array specifiers as `int[]` or `int[2]`       |\n| bytes | `HexString`, `Uint8Array`       | Raw bytes. You can also use fixed length bytes as `bytes[2]`                                                                                              |\n\n| string | `string` | String values |\n| address | `string`, `HexString` | Ethereum network compatible address |\n| bloom | `string`, `HexString` | Check if a given string is a Eth bloom |\n| 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']]` |\n\nFor the ethereum compatible data values should be passed as arrays e.g. for schema `['uint', 'string']` value should be passed as `[2, 'my-string']`.\n\nYou can also pass full ABI schema for the validation. e.g.\n\n```json\n[{ \"name\": \"owner\", \"type\": \"address\" }]\n```\n\nThe 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.\n\n## Prerequisites\n\n-   :gear: [NodeJS](https://nodejs.org/) (LTS/Fermium)\n-   :toolbox: [Yarn](https://yarnpkg.com/)/[Lerna](https://lerna.js.org/)\n\n## Package.json Scripts\n\n| Script           | Description                                        |\n| ---------------- | -------------------------------------------------- |\n| clean            | Uses `rimraf` to remove `dist/`                    |\n| build            | Uses `tsc` to build package and dependent packages |\n| lint             | Uses `eslint` to lint package                      |\n| lint:fix         | Uses `eslint` to check and fix any warnings        |\n| format           | Uses `prettier` to format the code                 |\n| test             | Uses `jest` to run unit tests                      |\n| test:integration | Uses `jest` to run tests under `/test/integration` |\n| test:unit        | Uses `jest` to run tests under `/test/unit`        |\n\n[docs]: https://docs.web3js.org/\n[repo]: https://github.com/web3/web3.js/tree/4.x/packages/web3-validator\n[npm-image]: https://img.shields.io/github/package-json/v/web3/web3.js/4.x?filename=packages%2Fweb3-validator%2Fpackage.json\n[npm-url]: https://npmjs.org/package/web3-validator\n[downloads-image]: https://img.shields.io/npm/dm/web3-validator?label=npm%20downloads\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/ChainSafe/web3.js/issues"},"homepage":"https://github.com/ChainSafe/web3.js#readme","_id":"web3-validator@2.0.7-dev.9086b98.0","_nodeVersion":"16.20.2","_npmVersion":"lerna/6.6.2/node@v16.20.2+x64 (linux)","dist":{"integrity":"sha512-gUwuV0CGCOL77fs+2JK3DERUK1dWWYzvNRoW53DolAdukGZG8M8DY3Pp557fSM2DC3kxxOPgJ2AMBldbvsvpqQ==","shasum":"5b0a2ee21a83f55944b51e9d6b6993d8bb1d18bd","tarball":"http://registry-npm.ywwl.com/web3-validator/download/web3-validator-2.0.7-dev.9086b98.0.tgz","fileCount":184,"unpackedSize":957277,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA+cqNui1VkQFNB2lgkncNRsHyofRzV3ooBiJdhMysRVAiEApOCYI6Bi/l1PlEtoub8YlpQrUXmfHSQGKUeIAHFTInk="}],"size":186754,"noattachment":false,"key":"/web3-validator/-/web3-validator-2.0.7-dev.9086b98.0.tgz"},"_npmUser":{"name":"mpetrunic","email":"marin.petrunic@gmail.com"},"directories":{},"maintainers":[{"name":"luu-alex","email":"alex.luu@mail.utoronto.ca"},{"name":"mpetrunic","email":"marin.petrunic@gmail.com"},{"name":"jdevcs","email":"junaid@chainsafe.io"},{"name":"gregthegreek","email":"gregorymarkou@gmail.com"},{"name":"spacesailor","email":"signup@wyatt.email"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/web3-validator_2.0.7-dev.9086b98.0_1717075553810_0.3243285736914865"},"_hasShrinkwrap":false,"publish_time":1717075554083,"_cnpm_publish_time":1717075554083,"dist-tags":{"dev":"2.0.7-dev.bf16917.0","latest":"2.0.6","rc":"2.0.0-rc.0"}}