Skip to content

Commit 9a10a80

Browse files
committed
extend validation schema with nested folders
1 parent 1104bde commit 9a10a80

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

packages/cubejs-schema-compiler/src/compiler/CubeValidator.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,19 @@ const cubeSchema = inherit(baseSchema, {
790790
'object.xor': 'You must use either sql or sqlTable within a model, but not both'
791791
});
792792

793+
const folderSchema = Joi.object().keys({
794+
name: Joi.string().required(),
795+
includes: Joi.alternatives([
796+
Joi.string().valid('*'),
797+
Joi.array().items(
798+
Joi.alternatives([
799+
Joi.string().required(),
800+
Joi.link('#folderSchema'), // Can contain nested folders
801+
]),
802+
),
803+
]).required(),
804+
}).id('folderSchema');
805+
793806
const viewSchema = inherit(baseSchema, {
794807
isView: Joi.boolean().strict(),
795808
cubes: Joi.array().items(
@@ -817,13 +830,7 @@ const viewSchema = inherit(baseSchema, {
817830
'object.oxor': 'Using split together with prefix is not supported'
818831
})
819832
),
820-
folders: Joi.array().items(Joi.object().keys({
821-
name: Joi.string().required(),
822-
includes: Joi.alternatives([
823-
Joi.string().valid('*'),
824-
Joi.array().items(Joi.string().required())
825-
]).required(),
826-
})),
833+
folders: Joi.array().items(folderSchema),
827834
});
828835

829836
function formatErrorMessageFromDetails(explain, d) {

0 commit comments

Comments
 (0)