Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tsbuffer-validator

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsbuffer-validator - npm Package Compare versions

Comparing version 0.3.10 to 0.4.0

4

package.json
{
"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);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc