fix(v2): fix theme validation for prism field and add tests (#3210)

* fix(v2): fix theme validation for prism field

* chore(v2): minor changes

* chore(v2): remove unused dependencies
This commit is contained in:
Teik Jun 2020-08-05 21:27:32 +08:00 committed by GitHub
parent 0d7314a6f7
commit 8f0c00f3d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 131 additions and 63 deletions

View file

@ -6,7 +6,6 @@
*/
const path = require('path');
const Joi = require('@hapi/joi');
module.exports = function () {
return {
@ -30,21 +29,3 @@ module.exports = function () {
},
};
};
const ThemeConfigSchema = Joi.object({
prism: Joi.object({
theme: Joi.object({
plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
}),
darkTheme: Joi.object({
plain: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
styles: Joi.alternatives().try(Joi.array(), Joi.object()).required(),
}),
defaultLanguage: Joi.string(),
}),
});
module.exports.validateThemeConfig = ({validate, themeConfig}) => {
return validate(ThemeConfigSchema, themeConfig);
};