{"name":"web3-validator","version":"1.0.0-rc.0","author":{"name":"ChainSafe Systems"},"license":"LGPL-3.0","_id":"web3-validator@1.0.0-rc.0","maintainers":[{"name":"spacesailor","email":"signup@wyatt.email"},{"name":"jdevcs","email":"junaid@chainsafe.io"}],"homepage":"https://github.com/ChainSafe/web3.js#readme","bugs":{"url":"https://github.com/ChainSafe/web3.js/issues"},"dist":{"shasum":"bd49eb217284b814efbad7318332f69f64ddb4f8","tarball":"http://registry-npm.ywwl.com/web3-validator/download/web3-validator-1.0.0-rc.0.tgz","fileCount":107,"integrity":"sha512-AT54Jw3yXcLvEtc1/4/8agnilnVZSuiSNDrqLWLO0v9Ppu+xL/kpdCQTkprvTxDvhytSkR3N+IQie5THpED0Wg==","signatures":[{"sig":"MEYCIQDzCt/8tWUIqOJMDQyNsERIML0nxd+7ggywQBMrpjjzLwIhALsxADugkIpkpgTkb+rYL/aD92W0ADZZsdptyauwZBw7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":100036,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkC15EACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpy9w//edR2NcM/r8fJbPUUW78yZWM5EGavAC7LHdmFjJ2gg5BFjK8+\r\nezVkJnm8RS9RhbgGb4FFNQSjQwrmj00xo/ZuiJLk8OLpSKQD8MThoTuhA+Ah\r\n59NIZnvBqrFIU0qZnV+hJKCh/Oes0eWNSrRFDjdXBpDPGtOtotj7T73z5Prt\r\nmMYTVNRIAFv1wBOgiHE+Clb2qp03qxoqc7ka8hGiApiTmkqRXa96UeUZgLkm\r\nv/UkeekszB0T9zm+vW2+BujeOAHEGoVMomcJzUvq8+IGasuosDTjKohv8DxQ\r\nHuSdS6D1sLkCnGoz523O7aDAXbb97UfnLTlkuT0aTblr6svn31GXdNBY0bRa\r\n/yo061fJhMevhsFIFdiSFBMl6olbnuDvQSTfYUMqqHhYDpVc3DkDk7ZLDKVv\r\njdk2GlQ/jY3wTliEO3UIPh6mpzLRY+ltclDJG+NruwjzDyFdf1UJNfm6IVKO\r\nlQagxdrTkGKaDuKM5XS62JFMclltSnOy7+Wa9R+/uwtPt9GIGUm1EAApwp/q\r\ngrwSXb3bY6RmXxu4QxEkFMIbEn3pJDtm9XMAuwqFvOBbaPSnR3wEzsKdpkCt\r\nJpXlif60JTK6+xccgAWwynGB/Q8WnGjIb1x83gDwynXvMVPr60C2kfMPa1r5\r\ncj1zP8AZVRFm9kAKlQBCY2zlX/5wfRL97fI=\r\n=qaBv\r\n-----END PGP SIGNATURE-----\r\n","size":23121,"noattachment":false,"key":"/web3-validator/-/web3-validator-1.0.0-rc.0.tgz"},"main":"lib/index.js","types":"./lib/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[![Dependency Status][deps-image]][deps-url]\n[![Dev Dependency Status][deps-dev-image]][deps-dev-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 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`, `Buffer`           | 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]: http://web3js.readthedocs.io/en/4.0/\n[repo]: https://github.com/ChainSafe/web3.js/tree/4.x/packages/web3-validator\n[npm-image]: https://img.shields.io/npm/v/web3-core-method.svg\n[npm-url]: https://npmjs.com/package/web3-validator\n[deps-image]: https://david-dm.org/ethereum/web3.js/4.x/status.svg?path=tools/web3-validator\n[deps-url]: https://david-dm.org/ethereum/web3.js/4.x?path=tools/web3-validator\n[deps-dev-image]: https://david-dm.org/ethereum/web3.js/4.x/dev-status.svg?path=tools/web3-validator\n[deps-dev-url]: https://david-dm.org/ethereum/web3.js/4.x?type=dev&path=tools/web3-validator\n","engines":{"npm":">=6.12.0","node":">=14"},"gitHead":"e7d290c6921755dde95a029dec4d98aef05d4929","scripts":{"lint":"eslint --ext .js,.ts .","test":"jest --config=./test/unit/jest.config.js","build":"tsc --build","clean":"rimraf dist && rimraf lib","format":"prettier --write '**/*'","test:ci":"jest --coverage=true --coverage-reporters=json --verbose","lint:fix":"eslint --fix --ext .js,.ts .","prebuild":"yarn clean","build:web":"npx webpack","test:unit":"jest --config=./test/unit/jest.config.js","test:watch":"npm test -- --watch","build:check":"node -e \"require('./lib')\"","test:integration":"jest --config=./test/integration/jest.config.js --passWithNoTests","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"},"_npmUser":{"name":"jdevcs","email":"junaid@chainsafe.io"},"repository":{"url":"git+https://github.com/ChainSafe/web3.js.git","type":"git"},"_npmVersion":"lerna/5.4.3/node@v14.20.0+x64 (linux)","description":"JSON-Schema compatible validator for web3","directories":{},"_nodeVersion":"14.20.0","dependencies":{"ajv":"^8.11.0","web3-types":"^1.0.0-rc.0","web3-errors":"^1.0.0-rc.0","ethereum-cryptography":"^1.1.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^28.1.3","eslint":"^8.20.0","ts-jest":"^28.0.7","prettier":"^2.7.1","typescript":"^4.7.4","@types/jest":"^28.1.6","jest-extended":"^3.0.1","eslint-plugin-import":"^2.26.0","eslint-config-prettier":"^8.5.0","eslint-config-web3-base":"0.1.0","@typescript-eslint/parser":"^5.30.7","@typescript-eslint/eslint-plugin":"^5.30.7"},"_npmOperationalInternal":{"tmp":"tmp/web3-validator_1.0.0-rc.0_1678466628664_0.1278911668649636","host":"s3://npm-registry-packages"},"publish_time":1678466628799,"_cnpm_publish_time":1678466628799,"dist-tags":{"dev":"2.0.7-dev.bf16917.0","latest":"2.0.6","rc":"2.0.0-rc.0"}}