raml-typesystem
Advanced tools
Comparing version 0.0.53 to 0.0.54
@@ -424,9 +424,18 @@ "use strict"; | ||
MapPropertyIs.prototype.check = function (i, p) { | ||
var _this = this; | ||
if (i) { | ||
if (typeof i == 'object') { | ||
var fixedProperties = {}; | ||
if (this._owner != null) { | ||
this._owner.meta().filter(function (x) { return x instanceof PropertyIs; }).forEach(function (x) { | ||
fixedProperties[x.propertyName()] = true; | ||
}); | ||
} | ||
var rs = new ts.Status(ts.Status.OK, 0, "", this); | ||
Object.getOwnPropertyNames(i).forEach(function (n) { | ||
if (n.match(_this.regexp)) { | ||
var stat = _this.validateProp(i, n, _this.type, p); | ||
for (var _i = 0, _a = Object.getOwnPropertyNames(i); _i < _a.length; _i++) { | ||
var n = _a[_i]; | ||
if (fixedProperties[n]) { | ||
continue; | ||
} | ||
if (n.match(this.regexp)) { | ||
var stat = this.validateProp(i, n, this.type, p); | ||
if (!stat.isOk()) { | ||
@@ -436,3 +445,3 @@ rs.addSubStatus(stat); | ||
} | ||
}); | ||
} | ||
return rs; | ||
@@ -439,0 +448,0 @@ } |
@@ -1070,3 +1070,3 @@ "use strict"; | ||
}); | ||
it("pattern properties test", function () { | ||
it("pattern properties test 1", function () { | ||
var st = { | ||
@@ -1079,2 +1079,5 @@ types: { | ||
"/x/": "string" | ||
}, | ||
"example": { | ||
"x": 123 | ||
} | ||
@@ -1087,2 +1090,22 @@ } | ||
var val = t.validateType(ts.builtInRegistry()).isOk(); | ||
assert.isTrue(val); | ||
}); | ||
it("pattern properties test 2", function () { | ||
var st = { | ||
types: { | ||
t1: { | ||
type: "object", | ||
properties: { | ||
x: "number", | ||
"/x/": "string" | ||
}, | ||
"example": { | ||
"x": "abc" | ||
} | ||
} | ||
} | ||
}; | ||
var col = ps.parseJSONTypeCollection(st); | ||
var t = col.getType("t1"); | ||
var val = t.validateType(ts.builtInRegistry()).isOk(); | ||
assert.isTrue(!val); | ||
@@ -1158,19 +1181,2 @@ }); | ||
}); | ||
it("pattern properties new style", function () { | ||
var st = { | ||
types: { | ||
t1: { | ||
type: "object", | ||
properties: { | ||
x: "number", | ||
"/x/": "string" | ||
} | ||
} | ||
} | ||
}; | ||
var col = ps.parseJSONTypeCollection(st); | ||
var t = col.getType("t1"); | ||
var val = t.validateType(ts.builtInRegistry()).isOk(); | ||
assert.isTrue(!val); | ||
}); | ||
it("one more pattern properties test (new style)", function () { | ||
@@ -1177,0 +1183,0 @@ var st = { |
{ | ||
"name": "raml-typesystem", | ||
"version": "0.0.53", | ||
"version": "0.0.54", | ||
"main": "dist/src/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -431,4 +431,13 @@ /// <reference path="../typings/main.d.ts" /> | ||
if (typeof i == 'object') { | ||
var fixedProperties:any = {}; | ||
if(this._owner!=null) { | ||
this._owner.meta().filter(x=>x instanceof PropertyIs).forEach(x=> { | ||
fixedProperties[(<PropertyIs>x).propertyName()] = true; | ||
}); | ||
} | ||
var rs:ts.Status = new ts.Status(ts.Status.OK, 0, "",this); | ||
Object.getOwnPropertyNames(i).forEach(n=> { | ||
for(var n of Object.getOwnPropertyNames(i)){ | ||
if(fixedProperties[n]){ | ||
continue; | ||
} | ||
if (n.match(this.regexp)) { | ||
@@ -440,3 +449,3 @@ var stat = this.validateProp(i, n, this.type,p); | ||
} | ||
}); | ||
} | ||
return rs; | ||
@@ -443,0 +452,0 @@ } |
@@ -812,16 +812,16 @@ /// <reference path="../typings/main.d.ts" /> | ||
} | ||
if (x instanceof MapPropertyIs){ | ||
var mm:MapPropertyIs=x; | ||
Object.keys(knownPropertySet).forEach(c=>{ | ||
try { | ||
if (c.match(mm.regexpValue())) { | ||
var regexpText = '/' + mm.regexpValue().toString() + '/'; | ||
rs.addSubStatus(new Status(Status.WARNING, 0, "pattern property '" + regexpText + "' conflicts with property: " + c, this)); | ||
} | ||
} catch (e){ | ||
//ignore incorrect regexps here | ||
} | ||
}) | ||
} | ||
// if (x instanceof MapPropertyIs){ | ||
// var mm:MapPropertyIs=x; | ||
// Object.keys(knownPropertySet).forEach(c=>{ | ||
// try { | ||
// if (c.match(mm.regexpValue())) { | ||
// var regexpText = '/' + mm.regexpValue().toString() + '/'; | ||
// | ||
// rs.addSubStatus(new Status(Status.WARNING, 0, "pattern property '" + regexpText + "' conflicts with property: " + c, this)); | ||
// } | ||
// } catch (e){ | ||
// //ignore incorrect regexps here | ||
// } | ||
// }) | ||
// } | ||
}) | ||
@@ -828,0 +828,0 @@ if (Object.getOwnPropertyNames(rfds).length > 0) { |
@@ -1150,3 +1150,3 @@ import ps= require("./actualParse") | ||
}); | ||
it ("pattern properties test",function(){ | ||
it ("pattern properties test 1",function(){ | ||
var st={ | ||
@@ -1161,2 +1161,5 @@ | ||
"/x/":"string" | ||
}, | ||
"example": { | ||
"x" : 123 | ||
} | ||
@@ -1169,6 +1172,6 @@ } | ||
var val= t.validateType(ts.builtInRegistry()).isOk(); | ||
assert.isTrue(!val); | ||
assert.isTrue(val); | ||
}); | ||
it ("one more pattern properties test",function(){ | ||
it ("pattern properties test 2",function(){ | ||
var st={ | ||
@@ -1182,3 +1185,6 @@ | ||
x: "number", | ||
"/x2/":"string" | ||
"/x/":"string" | ||
}, | ||
"example": { | ||
"x" : "abc" | ||
} | ||
@@ -1191,6 +1197,6 @@ } | ||
var val= t.validateType(ts.builtInRegistry()).isOk(); | ||
assert.isTrue(val); | ||
assert.isTrue(!val); | ||
}); | ||
it ("no external types in properties ",function(){ | ||
it ("one more pattern properties test",function(){ | ||
var st={ | ||
@@ -1200,7 +1206,7 @@ | ||
types:{ | ||
t0:"{}", | ||
t1:{ | ||
type:"object", | ||
properties:{ | ||
x: "t0" | ||
x: "number", | ||
"/x2/":"string" | ||
} | ||
@@ -1213,6 +1219,6 @@ } | ||
var val= t.validateType(ts.builtInRegistry()).isOk(); | ||
assert.isTrue(!val); | ||
assert.isTrue(val); | ||
}); | ||
it ("no external types in components",function(){ | ||
it ("no external types in properties ",function(){ | ||
var st={ | ||
@@ -1226,3 +1232,3 @@ | ||
properties:{ | ||
x: "t0[]" | ||
x: "t0" | ||
} | ||
@@ -1238,3 +1244,3 @@ } | ||
}); | ||
it ("it is illegal to do semantic inheritance from external types",function(){ | ||
it ("no external types in components",function(){ | ||
var st={ | ||
@@ -1246,5 +1252,5 @@ | ||
t1:{ | ||
type:[ "object","t0"], | ||
type:"object", | ||
properties:{ | ||
x: "number" | ||
x: "t0[]" | ||
} | ||
@@ -1258,4 +1264,5 @@ } | ||
assert.isTrue(!val); | ||
}); | ||
it ("pattern properties new style",function(){ | ||
it ("it is illegal to do semantic inheritance from external types",function(){ | ||
var st={ | ||
@@ -1265,7 +1272,7 @@ | ||
types:{ | ||
t0:"{}", | ||
t1:{ | ||
type:"object", | ||
type:[ "object","t0"], | ||
properties:{ | ||
x: "number", | ||
"/x/":"string" | ||
x: "number" | ||
} | ||
@@ -1279,3 +1286,2 @@ } | ||
assert.isTrue(!val); | ||
}); | ||
@@ -1282,0 +1288,0 @@ it ("one more pattern properties test (new style)",function(){ |
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
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
1911792
42544