tsbuffer-validator
Advanced tools
Comparing version 0.3.10 to 0.4.0
{ | ||
"name": "tsbuffer-validator", | ||
"version": "0.3.10", | ||
"version": "0.4.0", | ||
"description": "Validator for TSBuffer values", | ||
@@ -37,3 +37,3 @@ "main": "index.js", | ||
"k8w-extend-native": "^1.1.0", | ||
"tsbuffer-schema": "^0.8.0" | ||
"tsbuffer-schema": "^0.9.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "nyc": { |
@@ -18,8 +18,5 @@ "use strict"; | ||
if (schema.type === 'Reference') { | ||
if (!this._proto[schema.path]) { | ||
throw new Error('Cannot find path: ' + schema.path); | ||
} | ||
var parsedSchema = this._proto[schema.path][schema.targetName]; | ||
var parsedSchema = this._proto[schema.target]; | ||
if (!parsedSchema) { | ||
throw new Error("Cannot find [" + schema.targetName + "] at " + schema.path); | ||
throw new Error("Cannot find reference target: " + schema.target); | ||
} | ||
@@ -26,0 +23,0 @@ if (this.isTypeReference(parsedSchema)) { |
@@ -27,3 +27,8 @@ import { TSBufferSchema, TSBufferProto } from 'tsbuffer-schema'; | ||
constructor(proto: TSBufferProto, options?: Partial<TSBufferValidatorOptions>); | ||
validate(value: any, path: string, symbolName: string): ValidateResult; | ||
/** | ||
* 验证 | ||
* @param value | ||
* @param schemaId 例如 a/b.ts 里的 Test类型 则ID为 a/b/Test | ||
*/ | ||
validate(value: any, schemaId: string): ValidateResult; | ||
validateBySchema(value: any, schema: TSBufferSchema): ValidateResult; | ||
@@ -30,0 +35,0 @@ validateBooleanType(value: any): ValidateResult; |
@@ -29,10 +29,12 @@ "use strict"; | ||
} | ||
TSBufferValidator.prototype.validate = function (value, path, symbolName) { | ||
/** | ||
* 验证 | ||
* @param value | ||
* @param schemaId 例如 a/b.ts 里的 Test类型 则ID为 a/b/Test | ||
*/ | ||
TSBufferValidator.prototype.validate = function (value, schemaId) { | ||
//获取Schema | ||
if (!this._proto[path]) { | ||
throw new Error("Cannot find path: " + path); | ||
} | ||
var schema = this._proto[path][symbolName]; | ||
var schema = this._proto[schemaId]; | ||
if (!schema) { | ||
throw new Error("Cannot find schema [" + symbolName + "] at " + path); | ||
throw new Error("Cannot find schema [" + schemaId + "]"); | ||
} | ||
@@ -39,0 +41,0 @@ return this.validateBySchema(value, schema); |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
0
55296
11
923
+ Addedtsbuffer-schema@0.9.2(transitive)
- Removedtsbuffer-schema@0.8.0(transitive)
Updatedtsbuffer-schema@^0.9.0