From c3e542d46e65e8d550aa741ab46cb02ddd02bc63 Mon Sep 17 00:00:00 2001 From: Sem Bauke Date: Mon, 3 Nov 2025 12:16:02 +0100 Subject: [PATCH] feat(curriculum): add language attribute validation for language superblocks (#63434) --- curriculum/schema/challenge-schema.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/curriculum/schema/challenge-schema.js b/curriculum/schema/challenge-schema.js index 6d2b84ba825..eac98c0856c 100644 --- a/curriculum/schema/challenge-schema.js +++ b/curriculum/schema/challenge-schema.js @@ -4,7 +4,8 @@ Joi.objectId = require('joi-objectid')(Joi); const { challengeTypes } = require('../../shared-dist/config/challenge-types'); const { chapterBasedSuperBlocks, - catalogSuperBlocks + catalogSuperBlocks, + languageSuperBlocks } = require('../../shared-dist/config/curriculum'); const { availableCharacters, @@ -227,7 +228,11 @@ const schema = Joi.object().keys({ }), forumTopicId: Joi.number(), id: Joi.objectId().required(), - lang: Joi.string(), + lang: Joi.string().when('superBlock', { + is: languageSuperBlocks, + then: Joi.valid('en-US', 'es', 'zh-CN').required(), + otherwise: Joi.valid('en') + }), instructions: Joi.string().when('challengeType', { is: [challengeTypes.pythonProject, challengeTypes.codeAllyCert], then: Joi.string().min(1).required(),