generated from Seekra/repository-template
Add settings validator unit test #113
@@ -43,8 +43,10 @@ export const validateSelectionOptions = function validateSelectionOptions (optio
|
||||
export const validateEntry = function validateEntry (entry, path) {
|
||||
assertType(entry.type, `${path}.type`);
|
||||
|
||||
assertString(entry.name, `${path}.name`);
|
||||
assertString(entry.i18n, `${path}.i18n`);
|
||||
|
||||
if (entry.type === 'section') {
|
||||
assertString(entry.name, `${path}.name`);
|
||||
if (!Array.isArray(entry.content)) {
|
||||
throw new Error(`[settings] "${path}.content" must be an array`);
|
||||
}
|
||||
@@ -54,9 +56,6 @@ export const validateEntry = function validateEntry (entry, path) {
|
||||
return;
|
||||
}
|
||||
|
||||
assertString(entry.name, `${path}.name`);
|
||||
assertString(entry.i18n, `${path}.i18n`);
|
||||
|
||||
if (entry.default !== undefined) {
|
||||
if (entry.type === 'bool' && typeof entry.default !== 'boolean') {
|
||||
throw new Error(`[settings] "${path}.default" must be a boolean`);
|
||||
|
||||
Reference in New Issue
Block a user