moringa
Version:
Kamboja helper for MongooseJS
40 lines (39 loc) • 1.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var kamboja_foundation_1 = require("kamboja-foundation");
var H = require("./helper");
var TypeChecker = (function () {
function TypeChecker(type, pathResolver) {
var _this = this;
this.type = type;
this.array = false;
this.valid = false;
if (type) {
var qualified = new kamboja_foundation_1.Resolver.QualifiedName(type, pathResolver);
this.qualified = qualified.isValid();
if (this.qualified) {
this.name = H.getName(qualified.className);
this.valid = true;
this.array = qualified.isArray();
}
else {
if (type.indexOf("[]", type.length - 2) > -1) {
this.array = true;
this.name = type.substr(0, type.length - 2).toLowerCase();
}
else
this.name = type.toLowerCase();
if (kamboja_foundation_1.Core.ValidationTypesAccepted
.some(function (x) { return _this.name.toLowerCase() == x; })) {
this.valid = true;
}
}
}
}
TypeChecker.prototype.isValid = function () { return this.valid; };
TypeChecker.prototype.isArray = function () { return this.array; };
TypeChecker.prototype.isQualifiedName = function () { return this.qualified; };
TypeChecker.prototype.getName = function () { return this.name; };
return TypeChecker;
}());
exports.TypeChecker = TypeChecker;