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

raml-typesystem

Package Overview
Dependencies
Maintainers
2
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raml-typesystem - npm Package Compare versions

Comparing version 0.0.66 to 0.0.67

8

dist/src/nominal-types.js

@@ -10,7 +10,5 @@ "use strict";

var _ = require("./utils");
global["extraInjectors"] = [];
//var extraInjections:Injector[]=[];
var extraInjections = [];
function registerInjector(i) {
// extraInjections.push(i);
global["extraInjectors"].push(i);
extraInjections.push(i);
}

@@ -22,3 +20,3 @@ exports.registerInjector = registerInjector;

this.adapters = [];
global["extraInjectors"].forEach(function (x) { return x.inject(_this); });
extraInjections.forEach(function (x) { return x.inject(_this); });
}

@@ -25,0 +23,0 @@ Adaptable.prototype.addAdapter = function (q) {

@@ -33,2 +33,10 @@ /// <reference path="../../typings/main.d.ts" />

validate(content: any, alreadyAccepted?: any[]): void;
/**
* Checks for z-schema messages related to the inability to assign to a property of non-object variables.
* @param message
*
* @returns null if related message is not detected, assigned value if it can be detected, and empty string
* if related message is detected, but assigned value can not be found.
*/
static checkIfNonObjectAssignmentFailure(message: string): string;
validateSelf(alreadyAccepted?: any[]): void;

@@ -35,0 +43,0 @@ private setupId(json, path);

@@ -317,2 +317,35 @@ /// <reference path="../typings/main.d.ts" />

};
/**
* Checks for z-schema messages related to the inability to assign to a property of non-object variables.
* @param message
*
* @returns null if related message is not detected, assigned value if it can be detected, and empty string
* if related message is detected, but assigned value can not be found.
*/
JSONSchemaObject.checkIfNonObjectAssignmentFailure = function (message) {
var underscoreValidatedMessage = "__$validated";
var nonObjectMessage = "called on non-object";
if (!message)
return null;
if (message.indexOf(underscoreValidatedMessage) != -1) {
var messageBeginning1 = "Cannot assign to read only property '__$validated' of ";
var messageBeginning2 = "Cannot create property '__$validated' on string '";
if (message.indexOf(messageBeginning1) == 0
&& message.length > messageBeginning1.length) {
return message.substr(messageBeginning1.length, message.length - messageBeginning1.length);
}
else if (message.indexOf(messageBeginning2) == 0
&& message.length > messageBeginning2.length + 1 &&
message.charAt(message.length - 1) == "'") {
return message.substr(messageBeginning2.length, message.length - messageBeginning2.length - 1);
}
return "";
}
else if (message.indexOf(nonObjectMessage) != -1) {
return "";
}
else {
return null;
}
};
JSONSchemaObject.prototype.validateSelf = function (alreadyAccepted) {

@@ -336,6 +369,9 @@ var _this = this;

var illegalRequiredMessageStart = "Cannot assign to read only property '__$validated' of ";
if (error.message && error.message.indexOf(illegalRequiredMessageStart) == 0
&& error.message.length > illegalRequiredMessageStart.length) {
var propertyName = error.message.substr(illegalRequiredMessageStart.length, error.message.length - illegalRequiredMessageStart.length);
var message = "Unexpected value '" + propertyName + "'";
var nonObjectAssignmentCheck = JSONSchemaObject.checkIfNonObjectAssignmentFailure(error.message);
if (nonObjectAssignmentCheck !== null) {
var propertyName = nonObjectAssignmentCheck;
var message = "Assignment to non-object.";
if (propertyName) {
message = "Unexpected value '" + propertyName + "'";
}
this.acceptErrors(key, [{

@@ -342,0 +378,0 @@ message: message,

{
"name": "raml-typesystem",
"version": "0.0.66",
"version": "0.0.67",
"main": "dist/src/index.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -17,4 +17,2 @@ import ti = require("./nominal-interfaces")

import _=require("./utils")
declare var global:any;
global["extraInjectors"]=[];

@@ -25,7 +23,6 @@ declare function require(s:string):any;

}
//var extraInjections:Injector[]=[];
const extraInjections:Injector[]=[];
export function registerInjector(i:Injector){
// extraInjections.push(i);
global["extraInjectors"].push(i);
extraInjections.push(i);
}

@@ -41,3 +38,3 @@

constructor(){
(<Injector[]>global["extraInjectors"]).forEach(x=>x.inject(this))
extraInjections.forEach(x=>x.inject(this))

@@ -44,0 +41,0 @@ }

@@ -428,2 +428,40 @@ /// <reference path="../typings/main.d.ts" />

/**
* Checks for z-schema messages related to the inability to assign to a property of non-object variables.
* @param message
*
* @returns null if related message is not detected, assigned value if it can be detected, and empty string
* if related message is detected, but assigned value can not be found.
*/
public static checkIfNonObjectAssignmentFailure(message : string) : string {
const underscoreValidatedMessage = "__$validated";
const nonObjectMessage = "called on non-object";
if (!message) return null;
if (message.indexOf(underscoreValidatedMessage) != -1) {
const messageBeginning1 = "Cannot assign to read only property '__$validated' of ";
const messageBeginning2 = "Cannot create property '__$validated' on string '";
if(message.indexOf(messageBeginning1) == 0
&& message.length > messageBeginning1.length) {
return message.substr(messageBeginning1.length,
message.length - messageBeginning1.length);
} else if (message.indexOf(messageBeginning2) == 0
&& message.length > messageBeginning2.length + 1 &&
message.charAt(message.length-1) == "'") {
return message.substr(messageBeginning2.length,
message.length - messageBeginning2.length - 1);
}
return "";
} else if (message.indexOf(nonObjectMessage) != -1) {
return "";
} else {
return null;
}
}
validateSelf(alreadyAccepted: any[] = []): void {

@@ -451,9 +489,11 @@ var key = exampleKey("__SCHEMA_VALIDATION__",this.schema,this.provider.contextPath());

if (error.message && error.message.indexOf(illegalRequiredMessageStart) == 0
&& error.message.length > illegalRequiredMessageStart.length) {
let nonObjectAssignmentCheck = JSONSchemaObject.checkIfNonObjectAssignmentFailure(error.message);
if (nonObjectAssignmentCheck !== null) {
let propertyName = error.message.substr(illegalRequiredMessageStart.length,
error.message.length - illegalRequiredMessageStart.length);
let propertyName = nonObjectAssignmentCheck;
let message = "Unexpected value '" + propertyName + "'";
let message = "Assignment to non-object.";
if (propertyName) {
message = "Unexpected value '" + propertyName + "'"
}

@@ -460,0 +500,0 @@ this.acceptErrors(key,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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