4a. import content from WP ; change design to reflect 4a
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user