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.54 to 0.0.55

custom_typings/jsonvalidation.d.ts

24

dist/src/datetime.js

@@ -20,7 +20,7 @@ "use strict";

if (!checkDate(value)) {
return new ts.Status(ts.Status.ERROR, 0, "date-only should match to yyyy-mm-dd pattern", this);
return new ts.Status(ts.Status.ERROR, 0, "'date-only' instance should match 'yyyy-mm-dd' pattern", this);
}
return ts.ok();
}
return new ts.Status(ts.Status.ERROR, 0, "date-only should be string matching to yyyy-mm-dd pattern ", this);
return new ts.Status(ts.Status.ERROR, 0, "'date-only' instance should match 'yyyy-mm-dd' pattern", this);
};

@@ -52,11 +52,11 @@ DateOnlyR.prototype.requiredType = function () {

if (!matches) {
return new ts.Status(ts.Status.ERROR, 0, "time-only should match to hh:mm:ss[.ff...] pattern", this);
return new ts.Status(ts.Status.ERROR, 0, "'time-only' instance should match 'hh:mm:ss[.ff...]' pattern", this);
}
var hhmmssTime = matches[1];
if (!checkTime(hhmmssTime)) {
return new ts.Status(ts.Status.ERROR, 0, "time-only should match to hh:mm:ss[.ff...] pattern", this);
return new ts.Status(ts.Status.ERROR, 0, "'time-only' instance should match 'hh:mm:ss[.ff...]' pattern", this);
}
return ts.ok();
}
return new ts.Status(ts.Status.ERROR, 0, "time-only should be string matching to hh:mm:ss[.ff...] pattern ", this);
return new ts.Status(ts.Status.ERROR, 0, "'time-only' instance should match 'hh:mm:ss[.ff...]' pattern", this);
};

@@ -85,3 +85,3 @@ TimeOnlyR.prototype.requiredType = function () {

if (!matches || matches.length < 3) {
return new ts.Status(ts.Status.ERROR, 0, "datetime-only should match to yyyy-mm-ddThh:mm:ss[.ff...] pattern", this);
return new ts.Status(ts.Status.ERROR, 0, "'datetime-only' instance should match 'yyyy-mm-ddThh:mm:ss[.ff...]' pattern", this);
}

@@ -91,7 +91,7 @@ var date = matches[1];

if (!checkDate(date) || !checkTime(time)) {
return new ts.Status(ts.Status.ERROR, 0, "datetime-only should match to yyyy-mm-ddThh:mm:ss[.ff...] pattern", this);
return new ts.Status(ts.Status.ERROR, 0, "'datetime-only' instance should match 'yyyy-mm-ddThh:mm:ss[.ff...]' pattern", this);
}
return ts.ok();
}
return new ts.Status(ts.Status.ERROR, 0, "datetime-only should be string matching to yyyy-mm-ddThh:mm:ss[.ff...] pattern ", this);
return new ts.Status(ts.Status.ERROR, 0, "'datetime-only' instance should be string matching 'yyyy-mm-ddThh:mm:ss[.ff...]' pattern", this);
};

@@ -133,3 +133,3 @@ DateTimeOnlyR.prototype.requiredType = function () {

if (!rfc3339Matches || rfc3339Matches.length < 3) {
return new ts.Status(ts.Status.ERROR, 0, "valid rfc3339 formatted string is expected", this);
return new ts.Status(ts.Status.ERROR, 0, "Valid rfc3339 formatted string is expected", this);
}

@@ -140,3 +140,3 @@ else {

if (!checkDate(date) || !checkTime(time)) {
return new ts.Status(ts.Status.ERROR, 0, "valid rfc3339 formatted string is expected", this);
return new ts.Status(ts.Status.ERROR, 0, "Valid rfc3339 formatted string is expected", this);
}

@@ -148,3 +148,3 @@ }

if (!(value.match(r1) || value.match(r2) || value.match(r3))) {
return new ts.Status(ts.Status.ERROR, 0, "valid rfc2616 formatted string is expected", this);
return new ts.Status(ts.Status.ERROR, 0, "Valid rfc2616 formatted string is expected", this);
}

@@ -154,3 +154,3 @@ }

}
return new ts.Status(ts.Status.ERROR, 0, "valid datetime formatted string is expected", this);
return new ts.Status(ts.Status.ERROR, 0, "Valid datetime formatted string is expected", this);
};

@@ -157,0 +157,0 @@ DateTimeR.prototype.requiredType = function () {

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

if (ignoreTypeAttr === void 0) { ignoreTypeAttr = false; }
if (global) {
var t;
if (annotation) {
t = collection.getAnnotationType(name);
}
else {
t = collection.getType(name);
}
if (t != null) {
return t;
}
}
return tc.parse(name, data, collection ? collection.getTypeRegistry() : ts.builtInRegistry(), defaultsToAny, annotation, global, ignoreTypeAttr);

@@ -103,0 +115,0 @@ }

/// <reference path="../../typings/main.d.ts" />
import ts = require("./typesystem");
import { Status } from "./typesystem";
import tsInterfaces = require("./typesystem-interfaces");

@@ -97,5 +98,7 @@ export declare class MetaInfo extends ts.TypeInformation {

}
export declare class DiscriminatorValue extends ts.TypeInformation {
export declare class DiscriminatorValue extends ts.Constraint {
_value: any;
constructor(_value: any);
protected strict: boolean;
constructor(_value: any, strict?: boolean);
check(i: any, path: tsInterfaces.IValidationPath): Status;
facetName(): string;

@@ -106,2 +109,3 @@ validateSelf(registry: ts.TypeRegistry): ts.Status;

kind(): tsInterfaces.MetaInformationKind;
isStrict(): boolean;
}

@@ -90,3 +90,3 @@ "use strict";

if (!tp) {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "using unknown annotation type:" + this.facetName(), this);
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "Using unknown annotation type: '" + this.facetName() + "'", this);
}

@@ -101,4 +101,5 @@ var q = this.value();

if (!valOwner.isOk()) {
var res = new typesystem_1.Status(typesystem_1.Status.OK, 0, "invalid annotation value" + valOwner.getMessage(), this);
var res = new typesystem_1.Status(typesystem_1.Status.OK, 0, "Invalid annotation value " + valOwner.getMessage(), this);
res.addSubStatus(valOwner);
res.setValidationPath({ name: "(" + this.facetName() + ")" });
return res;

@@ -165,3 +166,3 @@ }

if (type.isObject() || type.isArray()) {
var c = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "Can not parse JSON example:" + e.message, this);
var c = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "Can not parse JSON example: " + e.message, this);
return c;

@@ -212,3 +213,3 @@ }

if (val.strict && typeof val.strict != "boolean") {
var s = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "strict should be boolean", this);
var s = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "'strict' should be boolean", this);
s.setValidationPath({ name: "example", child: { name: "strict" } });

@@ -230,3 +231,3 @@ return s;

}
var c = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "using invalid `example`:" + valOwner.getMessage(), this);
var c = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "Using invalid 'example': " + valOwner.getMessage(), this);
valOwner.getErrors().forEach(function (x) {

@@ -294,3 +295,3 @@ c.addSubStatus(x);

if (typeof this.value() !== "boolean") {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "value of required facet should be boolean", this);
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "Value of required facet should be boolean", this);
}

@@ -387,3 +388,3 @@ return ts.ok();

if (v[x].strict && typeof v[x].strict != "boolean") {
var s = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "strict should be boolean", _this);
var s = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "'strict' should be boolean", _this);
s.setValidationPath({ name: x, child: { name: "strict", child: { name: "strict" } } });

@@ -399,3 +400,3 @@ return s;

}
var res = _this.owner().validateDirect(example, true, false);
var res = _this.owner().validate(example, true, false);
res.getErrors().forEach(function (ex) {

@@ -419,3 +420,3 @@ rs.addSubStatus(ex);

else {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "examples should be a map", this);
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "'examples' value should be a map", this);
}

@@ -456,3 +457,3 @@ };

if (!valOwner.isOk()) {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "using invalid `defaultValue`:" + valOwner.getMessage(), this);
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "Using invalid 'defaultValue': " + valOwner.getMessage(), this);
}

@@ -482,16 +483,23 @@ return ts.ok();

var _this = this;
if (!this.owner().isSubTypeOf(ts.OBJECT)) {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "you only can use `discriminator` with object types", this);
var result = ts.ok();
if (this.owner().isUnion()) {
result = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "You can not specify 'discriminator' for union types", this);
}
if (this.owner().getExtra(ts.GLOBAL) === false) {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "you only can use `discriminator` with top level type definitions", this);
else if (!this.owner().isSubTypeOf(ts.OBJECT)) {
result = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "You only can use 'discriminator' with object types", this);
}
var prop = _.find(this.owner().meta(), function (x) { return x instanceof restrictions_1.PropertyIs && x.propertyName() == _this.value(); });
if (!prop) {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "Using unknown property '" + this.value() + "' as discriminator", this, true);
else if (this.owner().getExtra(ts.GLOBAL) === false) {
result = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "You can not specify 'discriminator' for inline type declarations", this);
}
if (!prop.value().isScalar()) {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "It is only allowed to use scalar properties as discriminators", this);
else {
var prop = _.find(this.owner().meta(), function (x) { return x instanceof restrictions_1.PropertyIs && x.propertyName() == _this.value(); });
if (!prop) {
result = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "Using unknown property '" + this.value() + "' as discriminator", this, true);
}
else if (!prop.value().isScalar()) {
result = new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "It is only allowed to use scalar properties as discriminators", this);
}
}
return ts.ok();
result.setValidationPath({ name: this.facetName() });
return result;
};

@@ -506,17 +514,56 @@ Discriminator.prototype.kind = function () {

__extends(DiscriminatorValue, _super);
function DiscriminatorValue(_value) {
function DiscriminatorValue(_value, strict) {
if (strict === void 0) { strict = true; }
_super.call(this, false);
this._value = _value;
this.strict = strict;
}
DiscriminatorValue.prototype.check = function (i, path) {
var owner = this.owner(); //_.find([t].concat(t.allSuperTypes()),x=>x.getExtra(TOPLEVEL));
var dVal = this.value();
var discriminator = owner.metaOfType(Discriminator);
if (discriminator.length == 0) {
return ts.ok();
}
var dName = discriminator[0].value();
// if(owner) {
// dVal = owner.name();
// }
// var discriminatorValue = t.metaOfType(metaInfo.DiscriminatorValue);
// if(discriminatorValue.length!=0){
// dVal = discriminatorValue[0].value();
// }
if (dVal) {
if (i.hasOwnProperty(dName)) {
var adVal = i[dName];
if (adVal != dVal) {
var wrng = new typesystem_1.Status(typesystem_1.Status.WARNING, typesystem_1.Status.CODE_INCORRECT_DISCRIMINATOR, "None of the '" + owner.name() + "' type known subtypes declare '" + adVal + "' as value of discriminating property '" + dName + "'.", this);
//var wrng = new Status(Status.WARNING, Status.CODE_INCORRECT_DISCRIMINATOR, dVal, this);
wrng.setValidationPath({ name: dName, child: path });
return wrng;
}
return ts.ok();
}
else {
var err = new typesystem_1.Status(typesystem_1.Status.ERROR, typesystem_1.Status.CODE_MISSING_DISCRIMINATOR, "Instance of '" + owner.name() + "' subtype misses value of the discriminating property '" + dName + "'.", this);
//var err = new Status(Status.ERROR, Status.CODE_MISSING_DISCRIMINATOR, dVal, this);
err.setValidationPath(path);
return err;
}
}
};
DiscriminatorValue.prototype.facetName = function () { return "discriminatorValue"; };
DiscriminatorValue.prototype.validateSelf = function (registry) {
if (!this.strict) {
return ts.ok();
}
if (!this.owner().isSubTypeOf(ts.OBJECT)) {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "you only can use `discriminator` with object types", this);
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "You only can use 'discriminator' with object types", this);
}
if (this.owner().getExtra(ts.GLOBAL) === false) {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "you only can use `discriminator` with top level type definitions", this);
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "You only can use 'discriminator' with top level type definitions", this);
}
var ds = this.owner().oneMeta(Discriminator);
if (!ds) {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "you can not use `discriminatorValue` without declaring `discriminator`", this);
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "You can not use 'discriminatorValue' without declaring 'discriminator'", this);
}

@@ -527,3 +574,3 @@ var prop = _.find(this.owner().meta(), function (x) { return x instanceof restrictions_1.PropertyIs && x.propertyName() == ds.value(); });

if (!sm.isOk()) {
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "using invalid `disciminatorValue`:" + sm.getMessage(), this);
return new typesystem_1.Status(typesystem_1.Status.ERROR, 0, "Using invalid 'disciminatorValue': " + sm.getMessage(), this);
}

@@ -542,5 +589,6 @@ }

};
DiscriminatorValue.prototype.isStrict = function () { return this.strict; };
return DiscriminatorValue;
}(ts.TypeInformation));
}(ts.Constraint));
exports.DiscriminatorValue = DiscriminatorValue;
//# sourceMappingURL=metainfo.js.map

@@ -301,3 +301,3 @@ "use strict";

if (tpes && tpes.kind() !== NodeKind.SCALAR) {
tpes.children().forEach(function (x) {
tpes.children().filter(function (x) { return x.key() && true; }).forEach(function (x) {
var t = ts.derive(x.key(), [ts.REFERENCE]);

@@ -309,3 +309,3 @@ result.add(t);

if (schemas && schemas.kind() !== NodeKind.SCALAR) {
schemas.children().forEach(function (x) {
schemas.children().filter(function (x) { return x.key() && true; }).forEach(function (x) {
var t = ts.derive(x.key(), [ts.REFERENCE]);

@@ -326,3 +326,3 @@ result.add(t);

if (tpes && tpes.kind() !== NodeKind.SCALAR) {
tpes.children().forEach(function (x) {
tpes.children().filter(function (x) { return x.key() && true; }).forEach(function (x) {
reg.get(x.key());

@@ -332,3 +332,3 @@ });

if (schemas && schemas.kind() !== NodeKind.SCALAR) {
schemas.children().forEach(function (x) {
schemas.children().filter(function (x) { return x.key() && true; }).forEach(function (x) {
reg.get(x.key());

@@ -537,2 +537,7 @@ });

}
else if (x instanceof meta.DiscriminatorValue) {
if (x.isStrict()) {
result.basicFacets.push(x);
}
}
else if (!(x instanceof meta.HasPropertiesFacet)) {

@@ -796,2 +801,5 @@ result.basicFacets.push(x);

});
if (result.metaOfType(meta.DiscriminatorValue).length == 0) {
result.addMeta(new meta.DiscriminatorValue(result.name(), false));
}
if (result.isSubTypeOf(ts.OBJECT)) {

@@ -809,3 +817,3 @@ var props = n.childWithKey("properties");

else {
var err = new ts.Status(ts.Status.ERROR, 2, "properties should be a map", actualResult);
var err = new ts.Status(ts.Status.ERROR, 2, "'properties' should be a map", actualResult);
err.setValidationPath({ name: "properties" });

@@ -829,3 +837,3 @@ result.putExtra(tsInterfaces.PARSE_ERROR, err);

else {
var err = new ts.Status(ts.Status.ERROR, 2, "facets should be a map", actualResult);
var err = new ts.Status(ts.Status.ERROR, 2, "'facets' should be a map", actualResult);
err.setValidationPath({ name: "facets" });

@@ -853,3 +861,11 @@ result.putExtra(tsInterfaces.PARSE_ERROR, err);

function contributeToAccumulatingRegistry(result, r) {
var existing = ts.TypeRegistry.prototype.get.call(r, result.name());
var existing;
var _r = r;
while (_r) {
existing = _r.typeMap()[result.name()];
if (existing) {
break;
}
_r = _r.parent();
}
if (existing == null || !existing.isSubTypeOf(ts.REFERENCE)) {

@@ -856,0 +872,0 @@ r.addType(result);

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

}
export declare function anotherRestrictionComponent(): any;
export declare function releaseAnotherRestrictionComponent(l?: number): void;
export declare function anotherRestrictionComponentsCount(): number;
/**

@@ -75,0 +78,0 @@ * this cosnstraint checks that map property values passes to particular type if exists

@@ -57,3 +57,3 @@ "use strict";

if (t.isUnknown() || t.isRecurrent()) {
var s = new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "Validating instance against unknown type:" + t.name(), this);
var s = new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "Validating instance against unknown type: '" + t.name() + "'", this);
s.setValidationPath(this.patchPath(q));

@@ -77,3 +77,3 @@ return s;

var actualUnknown = actualUnknownType(this._type);
var p = new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "property " + this.propId() + " refers to unknown type " + actualUnknown.name(), this);
var p = new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "Property '" + this.propId() + "' refers to unknown type '" + actualUnknown.name() + "'", this);
p.setValidationPath({ name: this.propId(), child: { name: "type" } });

@@ -85,3 +85,3 @@ return p;

if (!st.isOk()) {
var p = new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "property " + this.propId() + " range type has error:" + st.getMessage(), this);
var p = new typesystem_2.Status(typesystem_2.Status.ERROR, 0, ("Property '" + this.propId() + "' range type has error: ") + st.getMessage(), this);
st.getErrors().forEach(function (y) { p.addSubStatus(y); });

@@ -96,3 +96,3 @@ p.setValidationPath({ name: this.propId() });

if (ui) {
var p = new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "property " + this.propId() + " refers to unknown type " + ui.name(), this);
var p = new typesystem_2.Status(typesystem_2.Status.ERROR, 0, ("Property '" + this.propId() + "' refers to unknown type ") + ui.name(), this);
p.setValidationPath({ name: this.propId() });

@@ -125,3 +125,3 @@ return p;

catch (e) {
return new ts.Status(ts.Status.ERROR, 0, "Incorrect schema :" + e.message, this);
return new ts.Status(ts.Status.ERROR, 0, "Incorrect schema: " + e.message, this);
}

@@ -154,3 +154,3 @@ }

}
return new ts.Status(ts.Status.ERROR, 0, "Example does not conform to schema:" + e.message, this);
return new ts.Status(ts.Status.ERROR, 0, "Example does not conform to schema: " + e.message, this);
}

@@ -208,3 +208,3 @@ }

unknownPropertyNames.forEach(function (x) {
var err = ts.error("Unknown property:" + x, _this);
var err = ts.error("Unknown property: '" + x + "'", _this);
err.setValidationPath({ name: x });

@@ -255,3 +255,3 @@ s.addSubStatus(err);

}
return ts.error("Required property: " + this.name + " is missed", this);
return ts.error("Required property '" + this.name + "' is missing", this);
}

@@ -336,2 +336,3 @@ return ts.ok();

}
setAnotherRestrictionComponent(t);
var intersectionType = this.intersect(this.type, pi.type);

@@ -356,2 +357,31 @@ try {

exports.PropertyIs = PropertyIs;
var anotherSource = [];
function anotherRestrictionComponent() {
return anotherSource.length > 0 ? anotherSource[anotherSource.length - 1] : null;
}
exports.anotherRestrictionComponent = anotherRestrictionComponent;
function setAnotherRestrictionComponent(src) {
var owner;
while (src) {
owner = src.owner();
if (owner instanceof ts.InheritedType) {
src = owner.contextMeta();
}
else {
src = null;
}
}
anotherSource.push(owner);
}
function releaseAnotherRestrictionComponent(l) {
if (l === void 0) { l = 0; }
while (anotherSource.length > l) {
anotherSource.pop();
}
}
exports.releaseAnotherRestrictionComponent = releaseAnotherRestrictionComponent;
function anotherRestrictionComponentsCount() {
return anotherSource.length;
}
exports.anotherRestrictionComponentsCount = anotherRestrictionComponentsCount;
/**

@@ -682,11 +712,11 @@ * this cosnstraint checks that map property values passes to particular type if exists

if (typeof this._value != "number") {
return this.facetName() + " should be a number";
return "'" + this.facetName() + "' value should be a number";
}
if (this.isIntConstraint()) {
if (!is_int(this.value())) {
return this.facetName() + " should be a integer";
return "'" + this.facetName() + "' value should be an integer";
}
}
if (this.value() < this.minValue()) {
return this.facetName() + " should be at least " + this.minValue();
return this.facetName() + "' value should be at least " + this.minValue();
}

@@ -779,3 +809,3 @@ };

if (typeof this._value != "number") {
return this.facetName() + " should be a number";
return "'" + this.facetName() + "' value should be a number";
}

@@ -1003,3 +1033,3 @@ return null;

if (t.isUnknown() || t.isRecurrent()) {
var s = new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "array instance is validated against unknown type:" + t.name(), this);
var s = new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "Array instance is validated against unknown type: '" + t.name() + "'", this);
return s;

@@ -1018,3 +1048,3 @@ }

if (!st.isOk()) {
return new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "component type has error:" + st.getMessage(), this);
return new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "Component type has error: " + st.getMessage(), this);
}

@@ -1028,3 +1058,3 @@ return st;

if (this.type.isSubTypeOf(ts.UNKNOWN) || this.type.isSubTypeOf(ts.RECURRENT)) {
return new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "component refers to unknown type " + this.type.name(), this);
return new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "Component refers to unknown type '" + this.type.name() + "'", this);
}

@@ -1034,3 +1064,3 @@ if (this.type.isUnion()) {

if (ui) {
return new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "component refers to unknown type " + ui.name(), this);
return new typesystem_2.Status(typesystem_2.Status.ERROR, 0, "Component refers to unknown type '" + ui.name() + "'", this);
}

@@ -1100,3 +1130,3 @@ }

if (!gotMatch) {
return new ts.Status(ts.Status.ERROR, 0, "string should match to " + this.value(), this);
return new ts.Status(ts.Status.ERROR, 0, "String should match to '" + this.value() + "'", this);
}

@@ -1186,3 +1216,3 @@ }

if (!found) {
return "Following format values are allowed: " + allowedValues.join();
return "Following format values are allowed: " + allowedValues.map(function (x) { return ("'" + x + "'"); }).join(", ");
}

@@ -1241,3 +1271,3 @@ }

if (!this.owner().isSubTypeOf(this.requiredType())) {
return "enum facet can only be used with: " + this.requiredType().name();
return "'enum' facet can only be used with: " + this.requiredType().name();
}

@@ -1248,8 +1278,8 @@ if (this.requiredTypes() && this.requiredTypes().length > 0) {

if (!requiredSuperType) {
var typeNames = "[" + this.requiredTypes().map(function (requiredType) { return requiredType.name(); }).join() + "]";
return "enum facet can only be used with: " + typeNames;
var typeNames = "[" + this.requiredTypes().map(function (requiredType) { return ("'" + requiredType.name() + "'"); }).join(", ") + "]";
return "'enum' facet can only be used with: " + typeNames;
}
}
if (!Array.isArray(this._value)) {
return "enum facet value must be defined by array";
return "'enum' facet value must be defined by array";
}

@@ -1275,3 +1305,4 @@ // if (_.uniq(this._value).length<this._value.length){

Enum.prototype.toString = function () {
return "value should be one of:" + this._value;
var valStr = Array.isArray(this._value) ? this._value.map(function (x) { return ("'" + x + "'"); }).join(", ") : "'" + this._value + "'";
return "value should be one of: " + valStr;
};

@@ -1278,0 +1309,0 @@ return Enum;

@@ -5,4 +5,4 @@ /// <reference path="../typings/main.d.ts" />

var xmlUtil = require('./xmlUtil');
var jsonUtil = require('./jsonUtil');
var DOMParser = require('xmldom').DOMParser;
var ZSchema = require("z-schema");
var ValidationResult = (function () {

@@ -88,3 +88,3 @@ function ValidationResult() {

catch (err) {
throw new Error("It is not JSON schema(can not parse JSON:" + err.message + ")");
throw new Error("It is not JSON schema(can not parse JSON: " + err.message + ")");
}

@@ -137,4 +137,4 @@ if (!jsonSchemaObject) {

var result = [];
var validator = new ZSchema();
references.forEach(function (references) { return validator.setRemoteReference(references.reference, references.content || {}); });
var validator = jsonUtil.getValidator();
references.forEach(function (reference) { return validator.setRemoteReference(reference.reference, reference.content || {}); });
var schemaUrl = null;

@@ -159,3 +159,3 @@ if (this.jsonSchema.id && typeof (this.jsonSchema.id) === "string") {

filteredReferences = _.filter(result, function (referenceUrl) {
return validator.cache[referenceUrl] == null && referenceUrl != schemaUrl;
return !validator.isResourceLoaded(referenceUrl) && referenceUrl != schemaUrl;
});

@@ -244,3 +244,3 @@ return normalize ? filteredReferences.map(function (reference) { return _this.provider.normalizePath(reference); }) : filteredReferences;

}
var validator = new ZSchema();
var validator = jsonUtil.getValidator();
alreadyAccepted.forEach(function (accepted) { return validator.setRemoteReference(accepted.reference, accepted.content); });

@@ -300,3 +300,3 @@ validator.validate(JSON.parse(content), this.jsonSchema);

if (errors && errors.length > 0) {
var res = new Error("Content is not valid according to schema:" + errors.map(function (x) { return x.message + " " + x.params; }).join(", "));
var res = new Error("Content is not valid according to schema: " + errors.map(function (x) { return x.message + " " + x.params; }).join(", "));
res.errors = errors;

@@ -320,3 +320,3 @@ globalCache.setValue(key, res);

content: null,
error: new Error('Reference not found: ' + reference)
error: new Error("Reference not found: '" + reference + "'")
});

@@ -361,7 +361,7 @@ }

if (!this.extraElementData.type && !this.extraElementData.originalName) {
this.acceptErrors("key", [new Error('Referenced type "' + this.extraElementData.requestedName + '" is not match with "' + objectName + '" root node')], true);
this.acceptErrors("key", [new Error("Referenced type '" + this.extraElementData.requestedName + "' does not match '" + objectName + "' root node")], true);
return;
}
if (this.extraElementData.originalName && objectName !== this.extraElementData.originalName) {
this.acceptErrors("key", [new Error('Referenced type "' + this.extraElementData.requestedName + '" is not match with "' + objectName + '" root node')], true);
this.acceptErrors("key", [new Error("Referenced type '" + this.extraElementData.requestedName + "' does not match '" + objectName + "' root node")], true);
return;

@@ -423,3 +423,3 @@ }

if (errors && errors.length > 0) {
var res = new Error("Content is not valid according to schema:" + errors.map(function (x) { return x.message; }).join(", "));
var res = new Error("Content is not valid according to schema: " + errors.map(function (x) { return x.message; }).join(", "));
res.errors = errors;

@@ -426,0 +426,0 @@ globalCache.setValue(key, res);

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

static CODE_CONFLICTING_TYPE_KIND: number;
static CODE_INCORRECT_DISCRIMINATOR: number;
static CODE_MISSING_DISCRIMINATOR: number;
static ERROR: number;

@@ -23,3 +25,3 @@ static INFO: number;

patchPath(p: tsInterfaces.IValidationPath): tsInterfaces.IValidationPath;
setValidationPath(c: tsInterfaces.IValidationPath): void;
setValidationPath(_c: tsInterfaces.IValidationPath): void;
constructor(severity: number, code: number, message: string, source: any, takeNodeFromSource?: boolean);

@@ -33,5 +35,7 @@ addSubStatus(st: Status, pathName?: string): void;

getSource(): any;
getCode(): number;
isWarning(): boolean;
isError(): boolean;
isOk(): boolean;
isInfo(): boolean;
setSource(s: any): void;

@@ -72,3 +76,3 @@ toString(): string;

export declare abstract class Constraint extends TypeInformation {
constructor();
constructor(_inheritable?: boolean);
abstract check(i: any, parentPath: tsInterfaces.IValidationPath): Status;

@@ -115,2 +119,6 @@ private static intersections;

types(): AbstractType[];
typeMap(): {
[name: string]: AbstractType;
};
parent(): TypeRegistry;
}

@@ -120,3 +128,5 @@ export declare class RestrictionsConflict extends Status {

protected _stack: RestrictionStackEntry;
protected source: any;
constructor(_conflicting: Constraint, _stack: RestrictionStackEntry, source: any);
private computeMessage();
getConflictDescription(): string;

@@ -123,0 +133,0 @@ getConflicting(): Constraint;

/// <reference path="../typings/main.d.ts" />
"use strict";
var sss;
var XMLValidatorConstructor;

@@ -5,0 +4,0 @@ try {

@@ -513,3 +513,3 @@ /// <reference path="../typings/main.d.ts" />

it("All meta", function () {
assert.equal(facetRegistry.getInstance().allMeta().length, 12);
assert.equal(facetRegistry.getInstance().allMeta().length, 11);
});

@@ -516,0 +516,0 @@ });

@@ -355,3 +355,3 @@ "use strict";

assert(errors.length == 1);
assert(errors[0].message == "Required property: [] is missed");
assert(errors[0].message == "Required property '[]' is missing");
});

@@ -379,3 +379,3 @@ it("invalid pattern properties 2", function () {

assert(errors.length == 1);
assert(errors[0].message == "Required property: [] is missed");
assert(errors[0].message == "Required property '[]' is missing");
});

@@ -382,0 +382,0 @@ it("simple", function () {

@@ -73,3 +73,3 @@ "use strict";

st.getErrors().forEach(function (x) {
if (x.getMessage().indexOf("Required property:") != -1) {
if (x.getMessage().indexOf("Required property ") != -1) {
f = true;

@@ -259,3 +259,3 @@ }

assert.isTrue(st.getErrors().length === 1);
assert.isTrue(st.getMessage() === "Example does not conform to schema:Content is not valid according to schema:Additional properties not allowed: r r");
assert.isTrue(st.getMessage() === "Example does not conform to schema: Content is not valid according to schema: Additional properties not allowed: r r");
});

@@ -262,0 +262,0 @@ it("Valid example", function () {

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

@@ -8,3 +8,3 @@ "scripts": {

"noValidationBuild": "rimraf dist && tsc",
"build": "npm install raml-xml-validation && npm run noValidationBuild",
"build": "npm install raml-xml-validation && npm install raml-json-validation && npm run noValidationBuild",
"pullall": "dev-env-installer pullall",

@@ -21,3 +21,2 @@ "buildall": "dev-env-installer buildall",

"xml2js": "^0.4.16",
"z-schema": "^3.16.1",
"date-and-time": "0.3.0",

@@ -24,0 +23,0 @@ "xmldom": "^0.1.22"

@@ -16,7 +16,7 @@ declare function require(path:string):any

if (!checkDate(value)){
return new ts.Status(ts.Status.ERROR,0,"date-only should match to yyyy-mm-dd pattern",this)
return new ts.Status(ts.Status.ERROR,0,"'date-only' instance should match 'yyyy-mm-dd' pattern",this)
}
return ts.ok();
}
return new ts.Status(ts.Status.ERROR,0,"date-only should be string matching to yyyy-mm-dd pattern ",this)
return new ts.Status(ts.Status.ERROR,0,"'date-only' instance should match 'yyyy-mm-dd' pattern",this)
}

@@ -45,3 +45,3 @@ requiredType(){

if (!matches){
return new ts.Status(ts.Status.ERROR,0,"time-only should match to hh:mm:ss[.ff...] pattern",this)
return new ts.Status(ts.Status.ERROR,0,"'time-only' instance should match 'hh:mm:ss[.ff...]' pattern",this)
}

@@ -51,7 +51,7 @@

if (!checkTime(hhmmssTime)){
return new ts.Status(ts.Status.ERROR,0,"time-only should match to hh:mm:ss[.ff...] pattern",this)
return new ts.Status(ts.Status.ERROR,0,"'time-only' instance should match 'hh:mm:ss[.ff...]' pattern",this)
}
return ts.ok();
}
return new ts.Status(ts.Status.ERROR,0,"time-only should be string matching to hh:mm:ss[.ff...] pattern ",this)
return new ts.Status(ts.Status.ERROR,0,"'time-only' instance should match 'hh:mm:ss[.ff...]' pattern",this)
}

@@ -75,3 +75,3 @@ requiredType(){

if (!matches || matches.length < 3){
return new ts.Status(ts.Status.ERROR,0,"datetime-only should match to yyyy-mm-ddThh:mm:ss[.ff...] pattern",this)
return new ts.Status(ts.Status.ERROR,0,"'datetime-only' instance should match 'yyyy-mm-ddThh:mm:ss[.ff...]' pattern",this)
}

@@ -82,7 +82,7 @@

if (!checkDate(date) || !checkTime(time)) {
return new ts.Status(ts.Status.ERROR,0,"datetime-only should match to yyyy-mm-ddThh:mm:ss[.ff...] pattern",this)
return new ts.Status(ts.Status.ERROR,0,"'datetime-only' instance should match 'yyyy-mm-ddThh:mm:ss[.ff...]' pattern",this)
}
return ts.ok();
}
return new ts.Status(ts.Status.ERROR,0,"datetime-only should be string matching to yyyy-mm-ddThh:mm:ss[.ff...] pattern ",this)
return new ts.Status(ts.Status.ERROR,0,"'datetime-only' instance should be string matching 'yyyy-mm-ddThh:mm:ss[.ff...]' pattern",this)
}

@@ -123,3 +123,3 @@ requiredType(){

if (!rfc3339Matches || rfc3339Matches.length < 3){
return new ts.Status(ts.Status.ERROR,0,"valid rfc3339 formatted string is expected",this)
return new ts.Status(ts.Status.ERROR,0,"Valid rfc3339 formatted string is expected",this)
} else {

@@ -129,3 +129,3 @@ var date = rfc3339Matches[1];

if (!checkDate(date) || !checkTime(time)) {
return new ts.Status(ts.Status.ERROR,0,"valid rfc3339 formatted string is expected",this)
return new ts.Status(ts.Status.ERROR,0,"Valid rfc3339 formatted string is expected",this)
}

@@ -137,3 +137,3 @@ }

if (!(value.match(r1)||value.match(r2)||value.match(r3))){
return new ts.Status(ts.Status.ERROR,0,"valid rfc2616 formatted string is expected",this)
return new ts.Status(ts.Status.ERROR,0,"Valid rfc2616 formatted string is expected",this)
}

@@ -143,3 +143,3 @@ }

}
return new ts.Status(ts.Status.ERROR,0,"valid datetime formatted string is expected",this)
return new ts.Status(ts.Status.ERROR,0,"Valid datetime formatted string is expected",this)
}

@@ -146,0 +146,0 @@ requiredType(){

@@ -307,2 +307,14 @@ import ts=require("./typesystem")

ignoreTypeAttr:boolean=false):IParsedType {
if(global) {
var t:IParsedType;
if (annotation) {
t = collection.getAnnotationType(name);
}
else {
t = collection.getType(name);
}
if (t != null) {
return t;
}
}
return tc.parse(name,<any>data,collection? <ts.TypeRegistry>collection.getTypeRegistry():ts.builtInRegistry(),defaultsToAny,annotation,global,ignoreTypeAttr);

@@ -309,0 +321,0 @@ }

@@ -82,3 +82,3 @@ /// <reference path="../typings/main.d.ts" />

if (!tp){
return new Status(Status.ERROR,0,"using unknown annotation type:"+this.facetName(),this);
return new Status(Status.ERROR,0,`Using unknown annotation type: '${this.facetName()}'`,this);
}

@@ -93,4 +93,5 @@ var q=this.value();

if (!valOwner.isOk()){
var res=new Status(Status.OK,0,"invalid annotation value"+valOwner.getMessage(),this);
var res=new Status(Status.OK,0,"Invalid annotation value "+valOwner.getMessage(),this);
res.addSubStatus(valOwner);
res.setValidationPath({name:`(${this.facetName()})`});
return res;

@@ -153,3 +154,3 @@ }

if (type.isObject()||type.isArray()){
var c= new Status(Status.ERROR,0,"Can not parse JSON example:"+e.message,this);
var c= new Status(Status.ERROR,0,"Can not parse JSON example: "+e.message,this);
return c;

@@ -206,3 +207,3 @@ }

if (val.strict&&typeof val.strict!="boolean"){
var s= new Status(Status.ERROR,0,"strict should be boolean",this);
var s= new Status(Status.ERROR,0,"'strict' should be boolean",this);
s.setValidationPath({name: "example", child: {name: "strict"}})

@@ -226,3 +227,3 @@ return s;

}
var c= new Status(Status.ERROR,0,"using invalid `example`:"+valOwner.getMessage(),this);
var c= new Status(Status.ERROR,0,"Using invalid 'example': "+valOwner.getMessage(),this);
valOwner.getErrors().forEach(x=>{c.addSubStatus(x);

@@ -294,3 +295,3 @@ if (isVal) {

if (typeof this.value()!=="boolean"){
return new Status(Status.ERROR,0,"value of required facet should be boolean",this);
return new Status(Status.ERROR,0,"Value of required facet should be boolean",this);
}

@@ -393,3 +394,3 @@ return ts.ok();

if (v[x].strict&&typeof v[x].strict!="boolean"){
var s= new Status(Status.ERROR,0,"strict should be boolean",this);
var s= new Status(Status.ERROR,0,"'strict' should be boolean",this);
s.setValidationPath({name: x, child: {name: "strict", child: {name: "strict"}}});

@@ -405,3 +406,3 @@ return s;

}
var res = this.owner().validateDirect(example, true, false);
var res = this.owner().validate(example, true, false);
res.getErrors().forEach(ex=> {

@@ -425,3 +426,3 @@ rs.addSubStatus(ex);

else{
return new Status(Status.ERROR,0,"examples should be a map",this);
return new Status(Status.ERROR,0,"'examples' value should be a map",this);
}

@@ -462,3 +463,3 @@ }

if (!valOwner.isOk()){
return new Status(Status.ERROR,0,"using invalid `defaultValue`:"+valOwner.getMessage(),this);
return new Status(Status.ERROR,0,"Using invalid 'defaultValue': "+valOwner.getMessage(),this);
}

@@ -488,16 +489,23 @@ return ts.ok();

validateSelf(registry:ts.TypeRegistry):ts.Status {
if (!this.owner().isSubTypeOf(ts.OBJECT)){
return new Status(Status.ERROR,0,"you only can use `discriminator` with object types",this)
var result = ts.ok();
if (this.owner().isUnion()){
result = new Status(Status.ERROR,0,"You can not specify 'discriminator' for union types",this)
}
if (this.owner().getExtra(ts.GLOBAL)===false){
return new Status(Status.ERROR,0,"you only can use `discriminator` with top level type definitions",this)
else if (!this.owner().isSubTypeOf(ts.OBJECT)){
result = new Status(Status.ERROR,0,"You only can use 'discriminator' with object types",this);
}
var prop=_.find(this.owner().meta(),x=>x instanceof PropertyIs&& (<PropertyIs>x).propertyName()==this.value());
if (!prop){
return new Status(Status.ERROR,0,"Using unknown property '"+this.value()+"' as discriminator",this,true);
else if (this.owner().getExtra(ts.GLOBAL)===false){
result = new Status(Status.ERROR,0,"You can not specify 'discriminator' for inline type declarations",this)
}
if (!prop.value().isScalar()){
return new Status(Status.ERROR,0,"It is only allowed to use scalar properties as discriminators",this);
else {
var prop = _.find(this.owner().meta(), x=>x instanceof PropertyIs && (<PropertyIs>x).propertyName() == this.value());
if (!prop) {
result = new Status(Status.ERROR, 0, "Using unknown property '" + this.value() + "' as discriminator", this, true);
}
else if (!prop.value().isScalar()) {
result = new Status(Status.ERROR, 0, "It is only allowed to use scalar properties as discriminators", this);
}
}
return ts.ok();
result.setValidationPath({name:this.facetName()});
return result;
}

@@ -510,18 +518,58 @@

export class DiscriminatorValue extends ts.TypeInformation{
constructor(public _value: any){
export class DiscriminatorValue extends ts.Constraint{
constructor(public _value: any, protected strict:boolean=true){
super(false);
}
check(i:any,path:tsInterfaces.IValidationPath):Status{
var owner = this.owner();//_.find([t].concat(t.allSuperTypes()),x=>x.getExtra(TOPLEVEL));
var dVal:string = this.value();
var discriminator = owner.metaOfType(Discriminator);
if(discriminator.length==0){
return ts.ok();
}
var dName = discriminator[0].value();
// if(owner) {
// dVal = owner.name();
// }
// var discriminatorValue = t.metaOfType(metaInfo.DiscriminatorValue);
// if(discriminatorValue.length!=0){
// dVal = discriminatorValue[0].value();
// }
if(dVal) {
if (i.hasOwnProperty(dName)) {
var adVal = i[dName];
if (adVal != dVal) {
var wrng = new Status(Status.WARNING, Status.CODE_INCORRECT_DISCRIMINATOR,
`None of the '${owner.name()}' type known subtypes declare '${adVal}' as value of discriminating property '${dName}'.`, this);
//var wrng = new Status(Status.WARNING, Status.CODE_INCORRECT_DISCRIMINATOR, dVal, this);
wrng.setValidationPath({name: dName, child: path});
return wrng;
}
return ts.ok();
}
else {
var err = new Status(Status.ERROR, Status.CODE_MISSING_DISCRIMINATOR,
`Instance of '${owner.name()}' subtype misses value of the discriminating property '${dName}'.`, this);
//var err = new Status(Status.ERROR, Status.CODE_MISSING_DISCRIMINATOR, dVal, this);
err.setValidationPath(path);
return err;
}
}
}
facetName(){return "discriminatorValue"}
validateSelf(registry:ts.TypeRegistry):ts.Status {
if(!this.strict){
return ts.ok();
}
if (!this.owner().isSubTypeOf(ts.OBJECT)){
return new Status(Status.ERROR,0,"you only can use `discriminator` with object types",this)
return new Status(Status.ERROR,0,"You only can use 'discriminator' with object types",this)
}
if (this.owner().getExtra(ts.GLOBAL)===false){
return new Status(Status.ERROR,0,"you only can use `discriminator` with top level type definitions",this)
return new Status(Status.ERROR,0,"You only can use 'discriminator' with top level type definitions",this)
}
var ds=this.owner().oneMeta(Discriminator);
if (!ds){
return new Status(Status.ERROR,0,"you can not use `discriminatorValue` without declaring `discriminator`",this)
return new Status(Status.ERROR,0,"You can not use 'discriminatorValue' without declaring 'discriminator'",this)
}

@@ -532,3 +580,3 @@ var prop=_.find(this.owner().meta(),x=>x instanceof PropertyIs&& (<PropertyIs>x).propertyName()==ds.value());

if (!sm.isOk()){
return new Status(Status.ERROR,0,"using invalid `disciminatorValue`:"+sm.getMessage(),this);
return new Status(Status.ERROR,0,"Using invalid 'disciminatorValue': "+sm.getMessage(),this);
}

@@ -549,2 +597,4 @@ }

}
isStrict():boolean{ return this.strict; }
}

@@ -332,3 +332,3 @@ import ts=require("./typesystem")

if (tpes&&tpes.kind()!==NodeKind.SCALAR){
tpes.children().forEach(x=>{
tpes.children().filter(x=>x.key()&&true).forEach(x=>{
var t = ts.derive(x.key(),[ts.REFERENCE]);

@@ -340,3 +340,3 @@ result.add(t);

if (schemas&&schemas.kind()!==NodeKind.SCALAR){
schemas.children().forEach(x=>{
schemas.children().filter(x=>x.key()&&true).forEach(x=>{
var t = ts.derive(x.key(),[ts.REFERENCE]);

@@ -359,3 +359,3 @@ result.add(t);

if (tpes&&tpes.kind()!==NodeKind.SCALAR){
tpes.children().forEach(x=>{
tpes.children().filter(x=>x.key()&&true).forEach(x=>{
reg.get(x.key());

@@ -365,3 +365,3 @@ });

if (schemas&&schemas.kind()!==NodeKind.SCALAR){
schemas.children().forEach(x=>{
schemas.children().filter(x=>x.key()&&true).forEach(x=>{
reg.get(x.key());

@@ -589,2 +589,7 @@ });

}
else if(x instanceof meta.DiscriminatorValue){
if((<meta.DiscriminatorValue>x).isStrict()){
result.basicFacets.push(x);
}
}
else if(!(x instanceof meta.HasPropertiesFacet)) {

@@ -868,2 +873,5 @@ result.basicFacets.push(x);

});
if(result.metaOfType(meta.DiscriminatorValue).length==0){
result.addMeta(new meta.DiscriminatorValue(result.name(),false));
}
if (result.isSubTypeOf(ts.OBJECT)) {

@@ -881,3 +889,3 @@ var props=n.childWithKey("properties");

else{
var err=new ts.Status(ts.Status.ERROR,2,"properties should be a map",actualResult);
var err=new ts.Status(ts.Status.ERROR,2,"'properties' should be a map",actualResult);
err.setValidationPath({ name:"properties"})

@@ -902,3 +910,3 @@ result.putExtra(tsInterfaces.PARSE_ERROR,err);

else{
var err=new ts.Status(ts.Status.ERROR,2,"facets should be a map",actualResult);
var err=new ts.Status(ts.Status.ERROR,2,"'facets' should be a map",actualResult);
err.setValidationPath({ name:"facets"})

@@ -927,3 +935,12 @@ result.putExtra(tsInterfaces.PARSE_ERROR,err);

function contributeToAccumulatingRegistry(result:ts.InheritedType,r:TypeRegistry):ts.InheritedType {
var existing = ts.TypeRegistry.prototype.get.call(r,result.name());
var existing:ts.InheritedType;
var _r = r;
while(_r){
existing = <ts.InheritedType>_r.typeMap()[result.name()];
if(existing){
break;
}
_r = _r.parent();
}
if (existing == null || !existing.isSubTypeOf(ts.REFERENCE)) {

@@ -930,0 +947,0 @@ r.addType(result);

@@ -57,3 +57,3 @@ /// <reference path="../typings/main.d.ts" />

if (t.isUnknown()|| t.isRecurrent()){
var s=new Status(Status.ERROR,0,"Validating instance against unknown type:"+ t.name(),this);
var s=new Status(Status.ERROR,0,`Validating instance against unknown type: '${t.name()}'`,this);
s.setValidationPath(this.patchPath(q));

@@ -81,3 +81,3 @@ return s;

var actualUnknown = actualUnknownType(this._type);
var p= new Status(Status.ERROR,0,"property "+this.propId()+" refers to unknown type "+actualUnknown.name(),this)
var p= new Status(Status.ERROR,0,`Property '${this.propId()}' refers to unknown type '${actualUnknown.name()}'`,this);
p.setValidationPath({name: this.propId(), child: { name: "type"}})

@@ -89,6 +89,6 @@ return p;

if (!st.isOk()){
var p= new Status(Status.ERROR,0,"property "+this.propId()+" range type has error:"+st.getMessage(),this)
st.getErrors().forEach(y=>{p.addSubStatus(y)})
var p= new Status(Status.ERROR,0,`Property '${this.propId()}' range type has error: `+st.getMessage(),this);
st.getErrors().forEach(y=>{p.addSubStatus(y)});
p.setValidationPath({name: this.propId()})
p.setValidationPath({name: this.propId()});
return p;

@@ -102,3 +102,3 @@ }

if (ui){
var p=new Status(Status.ERROR,0,"property "+this.propId()+" refers to unknown type "+ui.name(),this);
var p=new Status(Status.ERROR,0,`Property '${this.propId()}' refers to unknown type `+ui.name(),this);
p.setValidationPath({name: this.propId()})

@@ -127,3 +127,3 @@ return p;

} catch (e){
return new ts.Status(ts.Status.ERROR,0,"Incorrect schema :"+ e.message,this);
return new ts.Status(ts.Status.ERROR,0,"Incorrect schema: "+ e.message,this);
}

@@ -154,3 +154,3 @@ }

}
return new ts.Status(ts.Status.ERROR,0,"Example does not conform to schema:"+e.message,this);
return new ts.Status(ts.Status.ERROR,0,"Example does not conform to schema: "+e.message,this);
}

@@ -214,3 +214,3 @@ //validate using classical schema;

unknownPropertyNames.forEach(x=>{
var err=ts.error("Unknown property:"+x,this);
var err=ts.error(`Unknown property: '${x}'`,this);
err.setValidationPath({name:x});

@@ -258,3 +258,3 @@ s.addSubStatus(err)}

}
return ts.error("Required property: " + this.name+" is missed",this);
return ts.error(`Required property '${this.name}' is missing`,this);
}

@@ -343,3 +343,4 @@ return ts.ok();

}
var intersectionType = this.intersect(this.type, pi.type);
setAnotherRestrictionComponent(t);
var intersectionType = this.intersect(this.type, pi.type);
try {

@@ -360,2 +361,32 @@ var is:ts.Status = intersectionType.checkConfluent();

}
var anotherSource:any[] = [];
export function anotherRestrictionComponent():any{
return anotherSource.length > 0 ? anotherSource[anotherSource.length-1] : null;
}
function setAnotherRestrictionComponent(src:Constraint){
var owner:AbstractType;
while(src){
owner = src.owner();
if(owner instanceof ts.InheritedType) {
src = (<ts.InheritedType>owner).contextMeta();
}
else{
src = null;
}
}
anotherSource.push(owner);
}
export function releaseAnotherRestrictionComponent(l:number=0){
while(anotherSource.length>l) {
anotherSource.pop();
}
}
export function anotherRestrictionComponentsCount():number{
return anotherSource.length;
}
/**

@@ -693,11 +724,11 @@ * this cosnstraint checks that map property values passes to particular type if exists

if (typeof this._value !="number"){
return this.facetName()+" should be a number";
return `'${this.facetName()}' value should be a number`;
}
if (this.isIntConstraint()){
if (!is_int(this.value())){
return this.facetName()+" should be a integer";
return `'${this.facetName()}' value should be an integer`;
}
}
if (this.value()<this.minValue()){
return this.facetName()+" should be at least "+this.minValue();
return `${this.facetName()}' value should be at least ${this.minValue()}`;
}

@@ -797,3 +828,3 @@ }

if (typeof this._value !="number"){
return this.facetName()+" should be a number";
return `'${this.facetName()}' value should be a number`;
}

@@ -1023,7 +1054,7 @@ return null;

if (t.isUnknown()|| t.isRecurrent()){
var s=new Status(Status.ERROR,0,"array instance is validated against unknown type:"+ t.name(),this);
var s=new Status(Status.ERROR,0,`Array instance is validated against unknown type: '${t.name()}'`,this);
return s;
}
}
ss.setValidationPath({ name:""+j})
ss.setValidationPath({ name:""+j});
rs.addSubStatus(ss);

@@ -1038,3 +1069,3 @@ }

if (!st.isOk()) {
return new Status(Status.ERROR, 0, "component type has error:" + st.getMessage(),this)
return new Status(Status.ERROR, 0, "Component type has error: " + st.getMessage(),this);
}

@@ -1044,7 +1075,7 @@ return st;

if (this.type.isExternal()){
var p= new Status(Status.ERROR,0,"It is not allowed to use external types in component type definitions",this)
var p= new Status(Status.ERROR,0,"It is not allowed to use external types in component type definitions",this);
return p;
}
if (this.type.isSubTypeOf(ts.UNKNOWN) || this.type.isSubTypeOf(ts.RECURRENT)) {
return new Status(Status.ERROR, 0, "component refers to unknown type " + this.type.name(),this)
return new Status(Status.ERROR, 0, `Component refers to unknown type '${this.type.name()}'`,this);
}

@@ -1054,3 +1085,3 @@ if (this.type.isUnion()) {

if (ui) {
return new Status(Status.ERROR, 0, "component refers to unknown type " + ui.name(),this)
return new Status(Status.ERROR, 0, `Component refers to unknown type '${ui.name()}'`,this)
}

@@ -1121,3 +1152,3 @@ }

if(!gotMatch){
return new ts.Status(ts.Status.ERROR, 0, "string should match to " + this.value(),this);
return new ts.Status(ts.Status.ERROR, 0, `String should match to '${this.value()}'`,this);
}

@@ -1210,3 +1241,3 @@ }catch (e){

if (!found) {
return "Following format values are allowed: " + allowedValues.join();
return "Following format values are allowed: " + allowedValues.map(x=>`'${x}'`).join(", ");
}

@@ -1267,3 +1298,3 @@ }

if (!this.owner().isSubTypeOf(this.requiredType())){
return "enum facet can only be used with: "+this.requiredType().name();
return "'enum' facet can only be used with: "+this.requiredType().name();
}

@@ -1274,8 +1305,8 @@ if (this.requiredTypes() && this.requiredTypes().length > 0) {

if (!requiredSuperType) {
var typeNames = "[" + this.requiredTypes().map(requiredType=>requiredType.name()).join() + "]";
return "enum facet can only be used with: " + typeNames;
var typeNames = "[" + this.requiredTypes().map(requiredType=>`'${requiredType.name()}'`).join(", ") + "]";
return "'enum' facet can only be used with: " + typeNames;
}
}
if(!Array.isArray(this._value)){
return "enum facet value must be defined by array";
return "'enum' facet value must be defined by array";
}

@@ -1300,3 +1331,4 @@ // if (_.uniq(this._value).length<this._value.length){

toString(){
return "value should be one of:" + this._value;
var valStr = Array.isArray(this._value) ? this._value.map(x=>`'${x}'`).join(", ") : `'${this._value}'`;
return "value should be one of: " + valStr;
}

@@ -1303,0 +1335,0 @@ }

/// <reference path="../typings/main.d.ts" />
import {XMLValidator} from "raml-xml-validation";
import {JSONValidator} from "raml-json-validation";
declare var global:any;

@@ -10,5 +12,5 @@ declare function require(s:string):any;

import xmlUtil = require('./xmlUtil');
import jsonUtil = require('./jsonUtil');
var DOMParser = require('xmldom').DOMParser;
var ZSchema=require("z-schema");

@@ -128,3 +130,3 @@ export class ValidationResult{

} catch(err){
throw new Error("It is not JSON schema(can not parse JSON:"+err.message+")");
throw new Error("It is not JSON schema(can not parse JSON: "+err.message+")");
}

@@ -183,5 +185,5 @@

var validator = new ZSchema();
var validator = jsonUtil.getValidator();
references.forEach(references => validator.setRemoteReference(references.reference, references.content || {}));
references.forEach(reference => validator.setRemoteReference(reference.reference, reference.content || {}));

@@ -210,3 +212,3 @@ var schemaUrl : string = null;

if (result) filteredReferences = _.filter(result, referenceUrl=>{
return validator.cache[referenceUrl] == null && referenceUrl != schemaUrl;
return !validator.isResourceLoaded(referenceUrl) && referenceUrl != schemaUrl;
})

@@ -320,3 +322,3 @@

var validator = new ZSchema();
var validator = jsonUtil.getValidator();

@@ -398,3 +400,3 @@ alreadyAccepted.forEach(accepted => validator.setRemoteReference(accepted.reference, accepted.content));

if(errors && errors.length>0){
var res= new Error("Content is not valid according to schema:"+errors.map(x=>x.message+" "+x.params).join(", "));
var res= new Error("Content is not valid according to schema: "+errors.map(x=>x.message+" "+x.params).join(", "));

@@ -426,3 +428,3 @@ (<any>res).errors=errors;

content: null,
error: new Error('Reference not found: ' + reference)
error: new Error(`Reference not found: '${reference}'`)
});

@@ -485,3 +487,4 @@ }

if(!this.extraElementData.type && !this.extraElementData.originalName) {
this.acceptErrors("key", [new Error('Referenced type "' + this.extraElementData.requestedName + '" is not match with "' + objectName + '" root node')], true);
this.acceptErrors("key", [new Error(
`Referenced type '${this.extraElementData.requestedName}' does not match '${objectName}' root node`)], true);

@@ -492,3 +495,4 @@ return;

if(this.extraElementData.originalName && objectName !== this.extraElementData.originalName) {
this.acceptErrors("key", [new Error('Referenced type "' + this.extraElementData.requestedName + '" is not match with "' + objectName + '" root node')], true);
this.acceptErrors("key", [new Error(
`Referenced type '${this.extraElementData.requestedName}' does not match '${objectName}' root node`)], true);

@@ -567,3 +571,3 @@ return;

if(errors && errors.length>0){
var res= new Error("Content is not valid according to schema:"+errors.map(x=>x.message).join(", "));
var res= new Error("Content is not valid according to schema: "+errors.map(x=>x.message).join(", "));

@@ -570,0 +574,0 @@ (<any>res).errors=errors;

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

public static CODE_INCORRECT_DISCRIMINATOR = 5;
public static CODE_MISSING_DISCRIMINATOR = 6;
public static ERROR = 3;

@@ -77,5 +81,5 @@

}
setValidationPath(c:tsInterfaces.IValidationPath){
setValidationPath(_c:tsInterfaces.IValidationPath){
if (this.vp){
c=this.patchPath(c);
var c=this.patchPath(_c);
var m=c;

@@ -89,6 +93,6 @@ while (m.child){

else {
this.vp = c;
this.vp = _c;
}
this.subStatus.forEach(x=>{
x.setValidationPath(this.vp);
x.setValidationPath(_c);
})

@@ -142,2 +146,5 @@ }

}
getCode(){
return this.code;
}
isWarning(){

@@ -152,2 +159,5 @@ return this.severity==Status.WARNING;

}
isInfo(){
return this.severity===Status.INFO;
}
setSource(s:any){

@@ -171,3 +181,3 @@ this.source=s;

}
putExtra(name:string,value:any):void{}

@@ -234,3 +244,3 @@

export abstract class Constraint extends TypeInformation{
constructor(){super(true)}
constructor(_inheritable=true){super(_inheritable)}

@@ -365,2 +375,10 @@

}
typeMap():{[name:string]: AbstractType}{
return this._types;
}
parent():TypeRegistry{
return this._parent;
}
}

@@ -452,20 +470,44 @@ interface PropertyInfoHandle{

export class RestrictionsConflict extends Status{
constructor(protected _conflicting:Constraint,protected _stack:RestrictionStackEntry,source:any){
constructor(protected _conflicting:Constraint,protected _stack:RestrictionStackEntry, protected source:any){
super(Status.ERROR,0,null,source);
this.computeMessage();
}
private computeMessage() {
var conflictingMessage:string = null;
if(_stack!=null){
if(_stack.getRestriction() instanceof restr.MinMaxRestriction){
var mmr:restr.MinMaxRestriction = <restr.MinMaxRestriction>_stack.getRestriction();
conflictingMessage = _conflicting.conflictMessage(mmr.facetPath(),mmr.value());
}
if (this._stack != null) {
if (this._stack.getRestriction() instanceof restr.MinMaxRestriction) {
var mmr:restr.MinMaxRestriction = <restr.MinMaxRestriction>this._stack.getRestriction();
conflictingMessage = this._conflicting.conflictMessage(mmr.facetPath(), mmr.value());
}
}
if(conflictingMessage==null){
conflictingMessage = _conflicting+" and "+(_stack!=null?_stack.getRestriction().toString():"");
if (conflictingMessage == null) {
conflictingMessage = this._conflicting + " and " + (this._stack != null ? this._stack.getRestriction().toString() : "");
}
var typeInfo:string = "";
if(source instanceof AbstractType){
typeInfo = `in type '${typePath(<AbstractType>source)}'`;
if (this.source instanceof AbstractType) {
var path:tsInterfaces.IValidationPath[] = [];
var rse = this._stack;
while (rse) {
var restri = rse.getRestriction();
if (restri instanceof PropertyIs) {
var vp:tsInterfaces.IValidationPath = {name: (<PropertyIs>restri).propId()};
if (path.length > 0) {
vp.child = path[path.length - 1];
}
path.push(vp);
}
rse = rse.pop();
}
this.setValidationPath(path.pop());
var arc = restr.anotherRestrictionComponent();
if(arc) {
typeInfo = ` between types '${typePath(<AbstractType>this.source)}' and '${typePath(<AbstractType>arc)}'`;
}
else{
typeInfo = ` in type '${typePath(<AbstractType>this.source)}'`;
}
}
this.message = `Restrictions conflict ${typeInfo}: ` + conflictingMessage;
this.message = `Restrictions conflict${typeInfo}: ` + conflictingMessage;
}

@@ -617,3 +659,3 @@

if (this.getExtra(SCHEMA_AND_TYPE)){
rs.addSubStatus(new Status(Status.ERROR,0, "schema and type are mutually exclusive",this));
rs.addSubStatus(new Status(Status.ERROR,0, "'schema' and 'type' are mutually exclusive",this));
}

@@ -646,3 +688,4 @@ if (rs.isOk()) {

if (required.hasOwnProperty(pr.propertyName())){
rs.addSubStatus(new Status(Status.ERROR,0,"Can not override required property:"+pr.propertyName()+" to be optional",this));
rs.addSubStatus(new Status(Status.ERROR,0,
`Can not override required property '${pr.propertyName()}' to be optional`,this));
}

@@ -654,3 +697,3 @@ }

propertyCycles.forEach(p=>{
var st=new Status(Status.ERROR,0,p+"has cyclic dependency",this);
var st=new Status(Status.ERROR,0,`'${p}' has cyclic dependency`,this);
st.setValidationPath({name:p})

@@ -673,3 +716,3 @@ rs.addSubStatus(st);

if (this.getExtra(tsInterfaces.TOP_LEVEL_EXTRA) && builtInRegistry().get(this.name())) {
rs.addSubStatus(new Status(Status.ERROR, 0, "redefining builtin type:" + this.name(), this))
rs.addSubStatus(new Status(Status.ERROR, 0, `Redefining a built in type: ${this.name()}`, this))

@@ -680,7 +723,7 @@ }

if (this.isSubTypeOf(RECURRENT)) {
rs.addSubStatus(new Status(Status.ERROR, 0, "recurrent type definition",this),"type")
rs.addSubStatus(new Status(Status.ERROR, 0, "Recurrent type definition",this),"type")
}
if (this.isSubTypeOf(UNKNOWN)) {
rs.addSubStatus(new Status(Status.ERROR, 0, "inheriting from unknown type",this),"type")
rs.addSubStatus(new Status(Status.ERROR, 0, "Inheriting from unknown type",this),"type")
}

@@ -690,6 +733,6 @@ if (this.isUnion()) {

if (tf.some(x=>x.isSubTypeOf(RECURRENT))) {
rs.addSubStatus(new Status(Status.ERROR, 0, "recurrent type as an option of union type",this),"type")
rs.addSubStatus(new Status(Status.ERROR, 0, "Recurrent type as an option of union type",this),"type")
}
if (tf.some(x=>x.isSubTypeOf(UNKNOWN))) {
rs.addSubStatus(new Status(Status.ERROR, 0, "unknown type as an option of union type",this),"type")
rs.addSubStatus(new Status(Status.ERROR, 0, "Unknown type as an option of union type",this),"type")
}

@@ -702,7 +745,8 @@ }

rs.addSubStatus(new Status(Status.ERROR, 0, "recurrent array type definition",this),ps)
rs.addSubStatus(new Status(Status.ERROR, 0, "Recurrent array type definition",this),ps)
}
else if (fs.some(x=>x===UNKNOWN)){
rs.addSubStatus(new Status(Status.ERROR, 0, "referring to unknown type "+this.oneMeta(ComponentShouldBeOfType).value().name()+" as an array component type",this),ps)
var componentTypeName = this.oneMeta(ComponentShouldBeOfType).value().name();
rs.addSubStatus(new Status(Status.ERROR, 0, `Referring to unknown type '${componentTypeName}' as an array component type`,this),ps)
}

@@ -737,3 +781,3 @@ }

if (this.getExtra(tsInterfaces.HAS_FACETS)){
var fs=new Status(Status.ERROR, 0, "External types can not declare facet '"+this.getExtra(tsInterfaces.HAS_FACETS)+"'",this);
var fs=new Status(Status.ERROR, 0, `External types can not declare facet '${this.getExtra(tsInterfaces.HAS_FACETS)}'`,this);
fs.setValidationPath({ name:this.getExtra(tsInterfaces.HAS_FACETS)});

@@ -794,3 +838,3 @@ rs.addSubStatus(fs);

if (super_facets.hasOwnProperty(an)){
rs.addSubStatus(new Status(Status.ERROR, 0, "facet :" + an+" can not be overriden",this))
rs.addSubStatus(new Status(Status.ERROR, 0, `Facet '${an}' can not be overriden`,this))

@@ -801,7 +845,7 @@ }

if (fp&&fp.isApplicable(this)||an=="type"||fd.facetName()=="properties"||an=="schema"||an=="facets"||an=="uses"){
rs.addSubStatus(new Status(Status.ERROR, 0, "built-in facet :" + an+" can not be overriden",this))
rs.addSubStatus(new Status(Status.ERROR, 0, `Built in facet '${an}' can not be overriden`,this))
}
if (an.charAt(0)=='('){
rs.addSubStatus(new Status(Status.ERROR, 0, "facet :" + an+" can not start from '('",this))
rs.addSubStatus(new Status(Status.ERROR, 0, `Facet '${an}' can not start from '('`,this))
}

@@ -826,4 +870,4 @@ }

else {
var msg = this.isExternal() ? "'" + cd.facetName() + "' facet is prohibited for external types"
: "specifying unknown facet:" + cd.facetName();
var msg = this.isExternal() ? `'${cd.facetName()}' facet is prohibited for external types`
: `Specifying unknown facet: '${cd.facetName()}'`;
rs.addSubStatus(new Status(Status.ERROR, 0, msg,cd,true))

@@ -839,3 +883,3 @@ }

//
// rs.addSubStatus(new Status(Status.WARNING, 0, "pattern property '" + regexpText + "' conflicts with property: " + c, this));
// rs.addSubStatus(new Status(Status.WARNING, 0, `Pattern property '${regexpText}' conflicts with property: '${c}'`, this));
// }

@@ -849,3 +893,3 @@ // } catch (e){

if (Object.getOwnPropertyNames(rfds).length > 0) {
rs.addSubStatus(new Status(Status.ERROR, 0, "missing required facets:" + Object.keys(rfds).join(","),this))
rs.addSubStatus(new Status(Status.ERROR, 0, "Missing required facets: " + Object.keys(rfds).map(x=>`'${x}'`).join(","),this))
}

@@ -898,6 +942,14 @@ };

isEmpty():boolean{
if (this.metaInfo.length>1){
if (this.metaInfo.length>2){
return false;
}
return this.metaInfo.filter(x=>!(x instanceof NotScalar)).length==0;
return this.metaInfo.filter(x=>{
if(x instanceof NotScalar){
return false;
}
else if(x instanceof metaInfo.DiscriminatorValue){
return (<metaInfo.DiscriminatorValue>x).isStrict();
}
return true;
}).length==0;
}

@@ -930,2 +982,3 @@

this.computeConfluent=true;
var arcc = restr.anotherRestrictionComponentsCount();
try {

@@ -942,3 +995,3 @@ var os = restr.optimize(this.restrictions());

}
var status=new RestrictionsConflict(another,lstack,this);
var status=new RestrictionsConflict(another,lstack,this);
return status;

@@ -949,2 +1002,3 @@ }

this.computeConfluent=false;
restr.releaseAnotherRestrictionComponent(arcc);
}

@@ -1173,9 +1227,35 @@ }

try {
for( var subType of this.subTypes()){
// for( var subType of this.subTypes()){
// var vr = subType.validateDirect(i,autoClose||g);
// if(vr.isOk()){
// return vr;
// }
// }
// return this.validateDirect(i, autoClose||g);
var statuses:Status[] = [];
var queue = this.subTypes().concat(this);
var lastStatus:Status;
for( var subType of queue){
var dStatus = checkDescriminator(i,subType);
var vr = subType.validateDirect(i,autoClose||g);
if(vr.isOk()){
if(dStatus){
if(dStatus.isOk()) {
return vr;
}
else {
statuses.push(dStatus);
}
}
else if(vr.isOk()){
return vr;
}
lastStatus = vr;
}
return this.validateDirect(i, autoClose||g);
if(statuses.length==0){
return lastStatus;
}
var result = ok();
statuses.forEach(x=>result.addSubStatus(x));
return statuses.pop();//result;
} finally {

@@ -1243,3 +1323,3 @@ autoCloseFlag=g;

checkDiscriminator(t1:AbstractType, t2:AbstractType):Status {
var found = new Status(Status.ERROR, 0, "can not discriminate types " + t1.name() + " and " + t2.name() + " without discriminator",this);
var found = new Status(Status.ERROR, 0, `Can not discriminate types '${t1.name()}' and '${t2.name()}' without discriminator`,this);
var oneMeta = t1.oneMeta(metaInfo.Discriminator);

@@ -1263,3 +1343,3 @@ var anotherMeta = t2.oneMeta(metaInfo.Discriminator);

found = new Status(Status.ERROR, 0,
"types" + t1.name() + " and " + t2.name() + " have same discriminator value",this);
`Types '${t1.name()}' and '${t2.name()}' have same discriminator value`,this);
}

@@ -1988,3 +2068,5 @@ return found;

if (this._extraMessage){
cs.addSubStatus(error(this._extraMessage,this));
var severity = 0;
results.forEach(x=>severity = Math.max(severity,x.getSeverity()));
cs.addSubStatus(new Status(severity,0,this._extraMessage,this));
}

@@ -2196,2 +2278,41 @@ }

return arr.reverse();
}
function checkDescriminator(i:any,t:AbstractType,path?:IValidationPath){
var discriminator = t.metaOfType(metaInfo.Discriminator);
if(discriminator.length!=0){
var dName = discriminator[0].value();
var owner = _.find([t].concat(t.allSuperTypes()),x=>x.getExtra(GLOBAL));
if(!owner) {
return null;
}
var dVal = owner.name();
var discriminatorValue = t.metaOfType(metaInfo.DiscriminatorValue);
if(discriminatorValue.length!=0){
dVal = discriminatorValue[0].value();
}
if(dVal) {
if (i.hasOwnProperty(dName)) {
var adVal = i[dName];
if (adVal != dVal) {
var wrng = new Status(Status.WARNING, Status.CODE_INCORRECT_DISCRIMINATOR,
`None of the '${owner.name()}' type known subtypes declare '${adVal}' as value of discriminating property '${dName}'.`, this);
//var wrng = new Status(Status.WARNING, Status.CODE_INCORRECT_DISCRIMINATOR, dVal, this);
wrng.setValidationPath({name: dName, child: path});
return wrng;
}
return ok();
}
else {
var err = new Status(Status.ERROR, Status.CODE_MISSING_DISCRIMINATOR,
`Instance of '${owner.name()}' subtype misses value of the discriminating property '${dName}'.`, this);
//var err = new Status(Status.ERROR, Status.CODE_MISSING_DISCRIMINATOR, dVal, this);
err.setValidationPath(path);
return err;
}
}
}
else{
return null;
}
}
/// <reference path="../typings/main.d.ts" />
import {XMLValidator} from "raml-xml-validation";
var sss: XMLValidator

@@ -6,0 +5,0 @@ declare function require(s:string):any;

@@ -523,3 +523,3 @@ /// <reference path="../typings/main.d.ts" />

it ("All meta",function (){
assert.equal(facetRegistry.getInstance().allMeta().length,12);
assert.equal(facetRegistry.getInstance().allMeta().length,11);
});

@@ -526,0 +526,0 @@ })

@@ -362,3 +362,3 @@ import ps= require("./actualParse")

assert(errors.length==1);
assert(errors[0].message=="Required property: [] is missed");
assert(errors[0].message=="Required property '[]' is missing");
});

@@ -387,3 +387,3 @@

assert(errors.length==1);
assert(errors[0].message=="Required property: [] is missed");
assert(errors[0].message=="Required property '[]' is missing");
});

@@ -390,0 +390,0 @@ it("simple", function () {

@@ -78,3 +78,3 @@ import ps= require("./actualParse")

st.getErrors().forEach((x: any)=>{
if (x.getMessage().indexOf("Required property:")!=-1){
if (x.getMessage().indexOf("Required property ")!=-1){
f=true;

@@ -303,3 +303,3 @@ }

assert.isTrue(st.getErrors().length===1);
assert.isTrue(st.getMessage()==="Example does not conform to schema:Content is not valid according to schema:Additional properties not allowed: r r")
assert.isTrue(st.getMessage()==="Example does not conform to schema: Content is not valid according to schema: Additional properties not allowed: r r")
});

@@ -306,0 +306,0 @@ it("Valid example", function () {

@@ -8,4 +8,5 @@ {

"xml2js": "github:DefinitelyTyped/DefinitelyTyped/xml2js/xml2js.d.ts#7304e0770d53762f89af7fcf14517d5f45a04cc2",
"xmlvalidation": "file:custom_typings/xmlvalidation.d.ts"
"xmlvalidation": "file:custom_typings/xmlvalidation.d.ts",
"jsonvalidation": "file:custom_typings/jsonvalidation.d.ts"
}
}

@@ -22,5 +22,10 @@ {

"build" : "npm run build",
"gitUrl" : "https://github.com/dreamflyer/raml-xml-validation.git",
"gitUrl" : "https://github.com/mulesoft-labs/raml-xml-validation.git",
"installTypings" : true
},
"raml-json-validation" : {
"build" : "npm run build",
"gitUrl" : "https://github.com/mulesoft-labs/raml-json-validation.git",
"installTypings" : true
},
"ts-structure-parser" : {

@@ -27,0 +32,0 @@ "build" : "npm run build",

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

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

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