web3-validator
Advanced tools
Comparing version 0.1.1-alpha.0 to 0.1.1-alpha.1
@@ -7,9 +7,4 @@ import { Web3Error } from 'web3-errors'; | ||
constructor(errors: Web3ValidationErrorObject[]); | ||
toJSON(): { | ||
name: string; | ||
message: string; | ||
code: number; | ||
}; | ||
private _compileErrors; | ||
} | ||
//# sourceMappingURL=errors.d.ts.map |
@@ -28,5 +28,2 @@ "use strict"; | ||
} | ||
toJSON() { | ||
return { name: this.name, message: this.message, code: this.code }; | ||
} | ||
_compileErrors() { | ||
@@ -33,0 +30,0 @@ const errorMsgs = this.errors.map(errorFormatter); |
@@ -227,2 +227,5 @@ "use strict"; | ||
} | ||
if (num < Number.MIN_SAFE_INTEGER) { | ||
return num; | ||
} | ||
return negative ? -1 * Number(num) : Number(num); | ||
@@ -229,0 +232,0 @@ }; |
@@ -31,3 +31,5 @@ "use strict"; | ||
const ajv_1 = __importDefault(require("ajv")); | ||
const utils_1 = require("./utils"); | ||
const blake2b_1 = require("ethereum-cryptography/blake2b"); | ||
const utils_1 = require("ethereum-cryptography/utils"); | ||
const utils_2 = require("./utils"); | ||
const eth_1 = require("./keywords/eth"); | ||
@@ -66,3 +68,3 @@ const errors_1 = require("./errors"); | ||
var _a, _b; | ||
const jsonSchema = (0, utils_1.ethAbiToJsonSchema)(schema); | ||
const jsonSchema = (0, utils_2.ethAbiToJsonSchema)(schema); | ||
if (Array.isArray(jsonSchema.items) && | ||
@@ -86,3 +88,7 @@ ((_a = jsonSchema.items) === null || _a === void 0 ? void 0 : _a.length) === 0 && | ||
} | ||
if (!this._validator.validate(jsonSchema, data)) { | ||
const schemaKey = (0, utils_1.toHex)((0, blake2b_1.blake2b)((0, utils_1.utf8ToBytes)(JSON.stringify(jsonSchema)))); | ||
if (!this._validator.getSchema(schemaKey)) { | ||
this._validator.addSchema(jsonSchema, schemaKey); | ||
} | ||
if (!this._validator.validate(schemaKey, data)) { | ||
const errors = this._validator.errors; | ||
@@ -89,0 +95,0 @@ if (options === null || options === void 0 ? void 0 : options.silent) { |
{ | ||
"name": "web3-validator", | ||
"version": "0.1.1-alpha.0", | ||
"version": "0.1.1-alpha.1", | ||
"description": "JSON-Schema compatible validator for web3", | ||
@@ -27,3 +27,3 @@ "main": "dist/index.js", | ||
"test:unit": "jest --config=./test/unit/jest.config.js", | ||
"test:integration": "jest --config=./test/integration/jest.config.js --runInBand --passWithNoTests" | ||
"test:integration": "jest --config=./test/integration/jest.config.js --passWithNoTests" | ||
}, | ||
@@ -33,4 +33,4 @@ "dependencies": { | ||
"ethereum-cryptography": "^1.1.2", | ||
"web3-errors": "^0.1.1-alpha.0", | ||
"web3-types": "^0.1.1-alpha.0" | ||
"web3-errors": "^0.1.1-alpha.1", | ||
"web3-types": "^0.1.1-alpha.1" | ||
}, | ||
@@ -51,3 +51,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "766ebd976ef71458eaebf7a6108b268881e30552" | ||
"gitHead": "a754e3a965c30f42a6e639df27462650062833ee" | ||
} |
@@ -17,5 +17,15 @@ <p align="center"> | ||
###### Get it from the NPM Registry | ||
## Installation | ||
You can install the package either using [NPM](https://www.npmjs.com/package/web3-validator) or using [Yarn](https://yarnpkg.com/package/web3-validator) | ||
### Using NPM | ||
```bash | ||
npm install web3-validator | ||
``` | ||
### Using Yarn | ||
```bash | ||
yarn add web3-validator | ||
@@ -22,0 +32,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1115995
2046
103
Updatedweb3-errors@^0.1.1-alpha.1
Updatedweb3-types@^0.1.1-alpha.1