| 12345678910111213141516171819202122232425262728293031323334353637 |
- import Joi from 'joi'
- import { allModules } from '..'
-
- /**
- * membership schema object
- * uses the module system to use common fields
- * but sets fields with our validation types
- * @constructor
- */
- const surveySchema = {
- type: 'object',
- properties: Joi.object().keys({
- /** _baseRecord fields */
- createdAt: Joi.string(),
- _id: Joi.string(),
- lastUpdatedAt: Joi.string(),
- type: Joi.string(),
-
- /** Survey fields */
- steps: Joi.array().items(
- Joi.object({
- id: Joi.number(),
- type: Joi.string(),
- question: Joi.string(),
- // TODO: specify responses to be array or null later
- responses: Joi.any(),
- })
- ).required(),
- }),
- /** fields required before saving */
- required: ['steps'],
- validate(instance) {
- return this.properties.validate(instance)
- },
- }
-
- export { surveySchema }
|