add support for custom fields

This commit is contained in:
Lachlan Kermode
2020-07-01 10:45:24 +02:00
parent e130b737e9
commit e985857d73
4 changed files with 70 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
import Joi from 'joi'
import eventSchema from './eventSchema'
import createEventSchema from './eventSchema'
import categorySchema from './categorySchema'
import siteSchema from './siteSchema'
import narrativeSchema from './narrativeSchema'
@@ -141,6 +141,11 @@ export function validateDomain (domain, features) {
})
}
if (!Array.isArray(features.CUSTOM_EVENT_FIELDS)) {
features.CUSTOM_EVENT_FIELDS = []
}
const eventSchema = createEventSchema(features.CUSTOM_EVENT_FIELDS)
validateArray(domain.events, 'events', eventSchema)
validateArray(domain.categories, 'categories', categorySchema)
validateArray(domain.sites, 'sites', siteSchema)