Skip to content

Commit 4b198a1

Browse files
authored
Merge pull request #645 from jeff-phillips-18/fixes
Valid seed examples when uploading a skill yaml file
2 parents e2c3d4c + b4ee79b commit 4b198a1

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/components/Contribute/Utils/uploadUtils.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,26 @@ export const addYamlUploadKnowledge = (knowledgeFormData: KnowledgeFormData, dat
4545
});
4646

4747
const yamlSkillSeedExampleToFormSeedExample = (yamlSeedExamples: { question: string; context?: string | undefined; answer: string }[]) => {
48-
return yamlSeedExamples.map((yamlSeedExample) => ({
49-
immutable: true,
50-
isExpanded: false,
51-
context: yamlSeedExample.context ?? '',
52-
questionAndAnswer: {
48+
return yamlSeedExamples.map((yamlSeedExample) => {
49+
const { context, question, answer } = yamlSeedExample;
50+
const { msg: questionValidationError, status: isQuestionValid } = validateQuestion(question);
51+
const { msg: answerValidationError, status: isAnswerValid } = validateQuestion(question);
52+
53+
return {
5354
immutable: true,
54-
question: yamlSeedExample.question,
55-
answer: yamlSeedExample.answer
56-
}
57-
})) as SkillSeedExample[];
55+
isExpanded: false,
56+
context,
57+
questionAndAnswer: {
58+
immutable: true,
59+
question,
60+
isQuestionValid,
61+
questionValidationError,
62+
answer,
63+
isAnswerValid,
64+
answerValidationError
65+
}
66+
};
67+
}) as SkillSeedExample[];
5868
};
5969

6070
export const addYamlUploadSkill = (skillFormData: SkillFormData, data: SkillYamlData): SkillFormData => ({

0 commit comments

Comments
 (0)