fix(tools): update challege formatting check

This commit is contained in:
Mrugesh Mohapatra
2019-08-01 20:13:05 +05:30
committed by mrugesh
parent 3ec1fe8ea7
commit 31f337f2bd
2 changed files with 17 additions and 11 deletions

View File

@ -41,6 +41,7 @@ function getSchemaForLang(lang) {
), ),
guideUrl: Joi.string().uri({ scheme: 'https' }), guideUrl: Joi.string().uri({ scheme: 'https' }),
videoUrl: Joi.string().allow(''), videoUrl: Joi.string().allow(''),
forumTopicId: Joi.number(),
helpRoom: Joi.string(), helpRoom: Joi.string(),
id: Joi.objectId().required(), id: Joi.objectId().required(),
instructions: Joi.string().allow(''), instructions: Joi.string().allow(''),

View File

@ -51,21 +51,26 @@ const challengeFrontmatterValidator = file => frontmatter => {
`); `);
} }
const { videoUrl } = frontmatter; const { videoUrl } = frontmatter;
let validVideoUrl = false; let validVideoUrl = false;
if (isEmpty(videoUrl)) { if (!isEmpty(videoUrl) && !scrimbaUrlRE.test(videoUrl)) {
validVideoUrl = true; validVideoUrl = true;
} else {
validVideoUrl = scrimbaUrlRE.test(videoUrl);
if (!validVideoUrl) {
console.log(` console.log(`
${fullPath} contains an invalid videoUrl ${fullPath} contains an invalid videoUrl
`); `);
} }
const { forumTopicId } = frontmatter;
let validForumTopicId = false;
if (!isEmpty(forumTopicId) && !isNumber(forumTopicId)) {
validForumTopicId = true;
console.log(`
${fullPath} contains an invalid forumTopicId
`);
} }
return hasRequiredProperties && validVideoUrl;
return hasRequiredProperties && validVideoUrl && validForumTopicId;
}; };
function isChallengeParseable(file) { function isChallengeParseable(file) {