Split collection config validator.
Also clarify collection validation messages.
This commit is contained in:
parent
864083bc8b
commit
db14b9747a
@ -12,12 +12,11 @@ const collections = (state = null, action) => {
|
|||||||
case CONFIG_SUCCESS:
|
case CONFIG_SUCCESS:
|
||||||
return OrderedMap().withMutations((map) => {
|
return OrderedMap().withMutations((map) => {
|
||||||
(configCollections || []).forEach((configCollection) => {
|
(configCollections || []).forEach((configCollection) => {
|
||||||
|
validateCollection(configCollection);
|
||||||
if (has(configCollection, 'folder')) {
|
if (has(configCollection, 'folder')) {
|
||||||
configCollection.type = FOLDER; // eslint-disable-line no-param-reassign
|
configCollection.type = FOLDER; // eslint-disable-line no-param-reassign
|
||||||
} else if (has(configCollection, 'files')) {
|
} else if (has(configCollection, 'files')) {
|
||||||
configCollection.type = FILES; // eslint-disable-line no-param-reassign
|
configCollection.type = FILES; // eslint-disable-line no-param-reassign
|
||||||
} else {
|
|
||||||
throw new Error('Unknown collection type. Collections can be either Folder based or File based. Please verify your site configuration');
|
|
||||||
}
|
}
|
||||||
map.set(configCollection.name, fromJS(configCollection));
|
map.set(configCollection.name, fromJS(configCollection));
|
||||||
});
|
});
|
||||||
@ -27,6 +26,13 @@ const collections = (state = null, action) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function validateCollection(configCollection) {
|
||||||
|
const collectionName = get(configCollection, 'name');
|
||||||
|
if (!has(configCollection, 'folder') && !has(configCollection, 'files')) {
|
||||||
|
throw new Error(`Unknown collection type for collection "${ collectionName }". Collections can be either Folder based or File based.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const selectors = {
|
const selectors = {
|
||||||
[FOLDER]: {
|
[FOLDER]: {
|
||||||
entryExtension(collection) {
|
entryExtension(collection) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user