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) {
|
export const validateEntry = function validateEntry (entry, path) {
|
||||||
assertType(entry.type, `${path}.type`);
|
assertType(entry.type, `${path}.type`);
|
||||||
|
|
||||||
if (entry.type === 'section') {
|
|
||||||
assertString(entry.name, `${path}.name`);
|
assertString(entry.name, `${path}.name`);
|
||||||
|
assertString(entry.i18n, `${path}.i18n`);
|
||||||
|
|
||||||
|
if (entry.type === 'section') {
|
||||||
if (!Array.isArray(entry.content)) {
|
if (!Array.isArray(entry.content)) {
|
||||||
throw new Error(`[settings] "${path}.content" must be an array`);
|
throw new Error(`[settings] "${path}.content" must be an array`);
|
||||||
}
|
}
|
||||||
@@ -54,9 +56,6 @@ export const validateEntry = function validateEntry (entry, path) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assertString(entry.name, `${path}.name`);
|
|
||||||
assertString(entry.i18n, `${path}.i18n`);
|
|
||||||
|
|
||||||
if (entry.default !== undefined) {
|
if (entry.default !== undefined) {
|
||||||
if (entry.type === 'bool' && typeof entry.default !== 'boolean') {
|
if (entry.type === 'bool' && typeof entry.default !== 'boolean') {
|
||||||
throw new Error(`[settings] "${path}.default" must be a boolean`);
|
throw new Error(`[settings] "${path}.default" must be a boolean`);
|
||||||
|
|||||||
Reference in New Issue
Block a user