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.78 to 0.0.79

4

dist/src/metainfo.d.ts

@@ -29,2 +29,6 @@ import ts = require("./typesystem");

}
export declare class AcceptAllScalarsAsStrings extends MetaInfo {
constructor();
kind(): tsInterfaces.MetaInformationKind;
}
export declare class SkipValidation extends MetaInfo {

@@ -31,0 +35,0 @@ constructor();

@@ -91,2 +91,13 @@ "use strict";

exports.ImportedByChain = ImportedByChain;
var AcceptAllScalarsAsStrings = /** @class */ (function (_super) {
__extends(AcceptAllScalarsAsStrings, _super);
function AcceptAllScalarsAsStrings() {
return _super.call(this, "acceptAllScalarsAsStrings", null, true) || this;
}
AcceptAllScalarsAsStrings.prototype.kind = function () {
return tsInterfaces.MetaInformationKind.AcceptAllScalarsAsStrings;
};
return AcceptAllScalarsAsStrings;
}(MetaInfo));
exports.AcceptAllScalarsAsStrings = AcceptAllScalarsAsStrings;
var SkipValidation = /** @class */ (function (_super) {

@@ -93,0 +104,0 @@ __extends(SkipValidation, _super);

@@ -1082,2 +1082,5 @@ "use strict";

checkIfSkipValidation(actualResult, n);
if (n.getMeta("acceptAllScalarsAsStrings")) {
actualResult.addMeta(new meta.AcceptAllScalarsAsStrings());
}
return actualResult;

@@ -1084,0 +1087,0 @@ }

40

dist/src/restrictions.js

@@ -14,2 +14,3 @@ "use strict";

var ts = require("./typesystem");
var bignumber_js_1 = require("bignumber.js");
var messageRegistry = ts.messageRegistry;

@@ -22,2 +23,3 @@ var su = require("./schemaUtil");

var metainfo_2 = require("./metainfo");
var metainfo_3 = require("./metainfo");
/**

@@ -724,29 +726,2 @@ * this class is an abstract super type for every constraint that can select properties from objects

exports.FacetRestriction = FacetRestriction;
function is_int(value) {
if (typeof Number.isInteger == "function") {
return Number.isInteger(value);
}
if (typeof value != "number" || isNaN(value)) {
return false;
}
var stringValue = "" + value;
var expInd = stringValue.indexOf("e");
var exp = 0;
var mantissa = stringValue;
if (expInd > 0) {
mantissa = stringValue.substring(0, expInd);
exp = parseInt(stringValue.substring(expInd + 1));
}
var dotInd = mantissa.indexOf(".");
var mantissaFractureLength = 0;
if (dotInd >= 0) {
mantissaFractureLength = mantissa.substring(dotInd + 1).length;
}
else {
for (var i = mantissa.length - 1; i >= 0 && mantissa.charAt(i) == '0'; i--) {
mantissaFractureLength--;
}
}
return exp >= mantissaFractureLength;
}
/**

@@ -812,3 +787,3 @@ * abstract super type for every min max restriction

if (this.isIntConstraint()) {
if (!is_int(this.value())) {
if (!new bignumber_js_1.BigNumber(this.value().toString()).isInteger()) {
return ts.error(messageRegistry.FACET_REQUIRE_INTEGER, this, { facetName: this.facetName() }, ts.Status.ERROR, true);

@@ -895,4 +870,6 @@ }

if (typeof o == 'number') {
var q = o / this.value();
if (!is_int(q)) {
var devided = new bignumber_js_1.BigNumber(o.toString());
var devisor = new bignumber_js_1.BigNumber(this.value().toString());
var quotient = devided.dividedBy(devisor);
if (!quotient.isInteger()) {
return ts.error(messageRegistry.EVEN_RATIO, this, { val1: o, val2: this.value() });

@@ -1415,2 +1392,5 @@ }

var opts = this.value();
if (this.owner().oneMeta(metainfo_3.AcceptAllScalarsAsStrings) && i != null) {
opts = opts.concat(opts.map(function (x) { return "" + x; }));
}
if (!Array.isArray(opts)) {

@@ -1417,0 +1397,0 @@ opts = [opts];

@@ -73,19 +73,20 @@ export interface IValidationPath {

ImportedByChain = 2,
SkipValidation = 3,
DisplayName = 4,
Usage = 5,
Annotation = 6,
FacetDeclaration = 7,
CustomFacet = 8,
Example = 9,
Required = 10,
HasPropertiesFacet = 11,
AllowedTargets = 12,
Examples = 13,
XMLInfo = 14,
Default = 15,
Constraint = 16,
Modifier = 17,
Discriminator = 18,
DiscriminatorValue = 19,
AcceptAllScalarsAsStrings = 3,
SkipValidation = 4,
DisplayName = 5,
Usage = 6,
Annotation = 7,
FacetDeclaration = 8,
CustomFacet = 9,
Example = 10,
Required = 11,
HasPropertiesFacet = 12,
AllowedTargets = 13,
Examples = 14,
XMLInfo = 15,
Default = 16,
Constraint = 17,
Modifier = 18,
Discriminator = 19,
DiscriminatorValue = 20,
}

@@ -92,0 +93,0 @@ /**

@@ -18,19 +18,20 @@ "use strict";

MetaInformationKind[MetaInformationKind["ImportedByChain"] = 2] = "ImportedByChain";
MetaInformationKind[MetaInformationKind["SkipValidation"] = 3] = "SkipValidation";
MetaInformationKind[MetaInformationKind["DisplayName"] = 4] = "DisplayName";
MetaInformationKind[MetaInformationKind["Usage"] = 5] = "Usage";
MetaInformationKind[MetaInformationKind["Annotation"] = 6] = "Annotation";
MetaInformationKind[MetaInformationKind["FacetDeclaration"] = 7] = "FacetDeclaration";
MetaInformationKind[MetaInformationKind["CustomFacet"] = 8] = "CustomFacet";
MetaInformationKind[MetaInformationKind["Example"] = 9] = "Example";
MetaInformationKind[MetaInformationKind["Required"] = 10] = "Required";
MetaInformationKind[MetaInformationKind["HasPropertiesFacet"] = 11] = "HasPropertiesFacet";
MetaInformationKind[MetaInformationKind["AllowedTargets"] = 12] = "AllowedTargets";
MetaInformationKind[MetaInformationKind["Examples"] = 13] = "Examples";
MetaInformationKind[MetaInformationKind["XMLInfo"] = 14] = "XMLInfo";
MetaInformationKind[MetaInformationKind["Default"] = 15] = "Default";
MetaInformationKind[MetaInformationKind["Constraint"] = 16] = "Constraint";
MetaInformationKind[MetaInformationKind["Modifier"] = 17] = "Modifier";
MetaInformationKind[MetaInformationKind["Discriminator"] = 18] = "Discriminator";
MetaInformationKind[MetaInformationKind["DiscriminatorValue"] = 19] = "DiscriminatorValue";
MetaInformationKind[MetaInformationKind["AcceptAllScalarsAsStrings"] = 3] = "AcceptAllScalarsAsStrings";
MetaInformationKind[MetaInformationKind["SkipValidation"] = 4] = "SkipValidation";
MetaInformationKind[MetaInformationKind["DisplayName"] = 5] = "DisplayName";
MetaInformationKind[MetaInformationKind["Usage"] = 6] = "Usage";
MetaInformationKind[MetaInformationKind["Annotation"] = 7] = "Annotation";
MetaInformationKind[MetaInformationKind["FacetDeclaration"] = 8] = "FacetDeclaration";
MetaInformationKind[MetaInformationKind["CustomFacet"] = 9] = "CustomFacet";
MetaInformationKind[MetaInformationKind["Example"] = 10] = "Example";
MetaInformationKind[MetaInformationKind["Required"] = 11] = "Required";
MetaInformationKind[MetaInformationKind["HasPropertiesFacet"] = 12] = "HasPropertiesFacet";
MetaInformationKind[MetaInformationKind["AllowedTargets"] = 13] = "AllowedTargets";
MetaInformationKind[MetaInformationKind["Examples"] = 14] = "Examples";
MetaInformationKind[MetaInformationKind["XMLInfo"] = 15] = "XMLInfo";
MetaInformationKind[MetaInformationKind["Default"] = 16] = "Default";
MetaInformationKind[MetaInformationKind["Constraint"] = 17] = "Constraint";
MetaInformationKind[MetaInformationKind["Modifier"] = 18] = "Modifier";
MetaInformationKind[MetaInformationKind["Discriminator"] = 19] = "Discriminator";
MetaInformationKind[MetaInformationKind["DiscriminatorValue"] = 20] = "DiscriminatorValue";
})(MetaInformationKind = exports.MetaInformationKind || (exports.MetaInformationKind = {}));

@@ -37,0 +38,0 @@ /**

@@ -1913,2 +1913,19 @@ "use strict";

});
it("multiple of (precision)", function () {
var st = {
types: {
t1: {
type: "number",
format: "long",
multipleOf: 0.001,
example: 99999999999.999
},
}
};
var col = ps.parseJSONTypeCollection(st);
var t = col.getType("t1");
var status = t.validateType(ts.builtInRegistry());
var val = status.isOk();
assert.isTrue(val);
});
it("multiple of (large numbers)", function () {

@@ -1915,0 +1932,0 @@ var st = {

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

@@ -16,9 +16,10 @@ "scripts": {

"dependencies": {
"date-and-time": "^0.5.0",
"json-schema-compatibility": "^1.1.0",
"json-to-ast": "^2.0.0-alpha1.3",
"lrucache": "^1.0.3",
"underscore": "^1.8.3",
"xml2js": "^0.4.19",
"xmldom": "^0.1.27"
"bignumber.js": "4.1.0",
"date-and-time": "0.5.0",
"json-schema-compatibility": "1.1.0",
"json-to-ast": "2.0.0-alpha1.3",
"lrucache": "1.0.3",
"underscore": "1.8.3",
"xml2js": "0.4.19",
"xmldom": "0.1.27"
},

@@ -48,18 +49,19 @@ "optionalDependencies": {

"devDependencies": {
"@types/chai": "^4.0.1",
"@types/mocha": "^2.2.41",
"@types/chai": "4.0.1",
"@types/mocha": "2.2.41",
"@types/node": "4.2.20",
"@types/underscore": "1.8.3",
"@types/xml2js": "0.4.0",
"chai": "^4.1.2",
"gulp": "^3.9.1",
"gulp-typedoc": "^2.1.0",
"istanbul": "^0.4.5",
"mocha": "^3.4.2",
"typedoc": "^0.3.12",
"@types/bignumber.js": "4.0.3",
"chai": "4.1.2",
"gulp": "3.9.1",
"gulp-typedoc": "2.1.0",
"istanbul": "0.4.5",
"mocha": "3.4.2",
"typedoc": "0.3.12",
"typescript": "2.5.2",
"dev-env-installer": "^0.0.14",
"json-loader": "^0.5.7",
"dev-env-installer": "0.0.14",
"json-loader": "0.5.7",
"rimraf": "*"
}
}

@@ -76,2 +76,13 @@ import ts=require("./typesystem");

export class AcceptAllScalarsAsStrings extends MetaInfo{
constructor(){
super("acceptAllScalarsAsStrings", null, true);
}
kind() : tsInterfaces.MetaInformationKind {
return tsInterfaces.MetaInformationKind.AcceptAllScalarsAsStrings;
}
}
export class SkipValidation extends MetaInfo{

@@ -78,0 +89,0 @@ constructor(){

@@ -1152,2 +1152,5 @@ import ts=require("./typesystem");

checkIfSkipValidation(actualResult, n);
if(n.getMeta("acceptAllScalarsAsStrings")){
actualResult.addMeta(new meta.AcceptAllScalarsAsStrings());
}
return actualResult;

@@ -1154,0 +1157,0 @@ }

import ts=require("./typesystem");
import {BigNumber} from "bignumber.js";
var messageRegistry = ts.messageRegistry;

@@ -11,2 +12,3 @@ import su=require("./schemaUtil")

import {SkipValidation} from "./metainfo";
import {AcceptAllScalarsAsStrings} from "./metainfo";
export type IValidationPath=ts.IValidationPath;

@@ -735,29 +737,2 @@ /**

}
function is_int(value:any){
if(typeof (<any>Number).isInteger == "function"){
return (<any>Number).isInteger(value);
}
if(typeof value != "number" || isNaN(value)){
return false;
}
let stringValue = ""+value;
let expInd = stringValue.indexOf("e");
let exp = 0;
let mantissa = stringValue;
if(expInd>0){
mantissa = stringValue.substring(0,expInd);
exp = parseInt(stringValue.substring(expInd+1));
}
let dotInd = mantissa.indexOf(".");
let mantissaFractureLength = 0;
if(dotInd>=0){
mantissaFractureLength = mantissa.substring(dotInd+1).length;
}
else{
for(let i = mantissa.length-1; i >= 0 && mantissa.charAt(i)=='0' ; i--){
mantissaFractureLength--;
}
}
return exp >= mantissaFractureLength;
}
/**

@@ -825,3 +800,3 @@ * abstract super type for every min max restriction

if (this.isIntConstraint()){
if (!is_int(this.value())){
if (!new BigNumber(this.value().toString()).isInteger()){
return ts.error(messageRegistry.FACET_REQUIRE_INTEGER,

@@ -911,5 +886,7 @@ this,{ facetName: this.facetName()},ts.Status.ERROR,true);

check(o:any):ts.Status{
if (typeof o=='number'){
var q=o/this.value();
if (!is_int(q)){
if (typeof o == 'number'){
let devided = new BigNumber(o.toString());
let devisor = new BigNumber(this.value().toString());
let quotient = devided.dividedBy(devisor);
if (!quotient.isInteger()){
return ts.error(messageRegistry.EVEN_RATIO, this, { val1: o, val2 : this.value() });

@@ -1442,2 +1419,5 @@ }

var opts = this.value();
if(this.owner().oneMeta(AcceptAllScalarsAsStrings)&&i!=null){
opts = opts.concat(opts.map(x=>""+x));
}
if (!Array.isArray(opts)){

@@ -1444,0 +1424,0 @@ opts=[<string><any>opts];

@@ -92,2 +92,3 @@ export interface IValidationPath{

ImportedByChain,
AcceptAllScalarsAsStrings,
SkipValidation,

@@ -94,0 +95,0 @@ DisplayName,

@@ -2169,2 +2169,23 @@ import ps= require("./actualParse")

it ("multiple of (precision)",function(){
var st={
types:{
t1:{
type:"number",
format: "long",
multipleOf: 0.001,
example: 99999999999.999
},
}
};
var col=ps.parseJSONTypeCollection(st);
var t=col.getType("t1");
var status=t.validateType(ts.builtInRegistry());
var val=status .isOk();
assert.isTrue(val);
});
it ("multiple of (large numbers)",function(){

@@ -2171,0 +2192,0 @@ var st={

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

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