lex-model-validator
Version:
Validate lex-language-models with ease.
47 lines (46 loc) • 2.03 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var __1 = require("../..");
var IntentValidator = /** @class */ (function (_super) {
__extends(IntentValidator, _super);
function IntentValidator() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.validateIntents = function (validationPair) {
var intents = validationPair.value;
if (intents && intents.length > 0) {
intents.forEach(function (intent, intentIndex) {
_this.validate(intent, __1.VALIDATION_CONSTRAINTS_INTENT, validationPair.key + ("[" + intentIndex + "]"));
if (intent.slots && intent.slots.length > 0) {
intent.slots.forEach(function (slot, slotIndex) {
_this.validate(slot, __1.VALIDATION_CONSTRAINTS_SLOT, validationPair.key + ("[" + intentIndex + "].slots[" + slotIndex + "]"));
});
}
});
}
};
return _this;
}
IntentValidator.prototype.getConstraints = function () {
return {
'resource.intents': {
isArray: true,
validate: this.validateIntents
}
};
};
return IntentValidator;
}(__1.Validator));
exports.IntentValidator = IntentValidator;