4a. import content from WP ; change design to reflect 4a

This commit is contained in:
GotPPay
2018-03-30 10:54:15 +02:00
parent 5484a9a461
commit 443dc53dbd
17 changed files with 3581 additions and 875 deletions

View File

@@ -26,7 +26,9 @@ validateQuestion = function (question) {
return validQuestionNameRegex.test (question);
};
validateAnswer = function (answer) {
validateAnswer = function (answer, answerType) {
if (answerType !== constants.answerType.PREDEFINED) return true;
if (
answer.length < constants.stringConstraints.ANSWER_MIN_LENGTH ||
answer.length > constants.stringConstraints.ANSWER_MAX_LENGTH
@@ -36,13 +38,18 @@ validateAnswer = function (answer) {
return validAnswerRegex.test (answer);
};
validateExternalAnswerSource = function (externalAnswerSource, answerType){
// TODO: implement validation logic
return true;
}
validateInvocationName = function (invocationName) {
if (
invocationName.length < constants.stringConstraints.INVOCATION_NAME_MIN_LENGTH ||
invocationName.length > constants.stringConstraints.INVOCATION_NAME_MAX_LENGTH
)
return false;
let validInvocationNameRegex = /^[a-z,.' ]*$/i;
let validInvocationNameRegex = /^[a-z,.' ]*$/;
return validInvocationNameRegex.test (invocationName);
};
@@ -69,10 +76,10 @@ module.exports = {
!validateInvocationAnswer (skill.invocationAnswer)
)
return false;
for (let i = 0; i < skill.intents.length; i++) {
if (!validateIntentName (skill.intents[i].intentName)) return false;
if (!validateAnswer (skill.intents[i].answer)) return false;
if (!validateAnswer (skill.intents[i].answer, skill.intents[i].answerType)) return false;
if (!validateExternalAnswerSource(skill.intents[i].externalAnswerSource, skill.intents[i].answerType)) return false;
for (let j = 0; j < skill.intents.length; j++) {
if (i === j) continue;