選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

survey.schema.js 963B

12345678910111213141516171819202122232425262728293031323334353637
  1. import Joi from 'joi'
  2. import { allModules } from '..'
  3. /**
  4. * membership schema object
  5. * uses the module system to use common fields
  6. * but sets fields with our validation types
  7. * @constructor
  8. */
  9. const surveySchema = {
  10. type: 'object',
  11. properties: Joi.object().keys({
  12. /** _baseRecord fields */
  13. createdAt: Joi.string(),
  14. _id: Joi.string(),
  15. lastUpdatedAt: Joi.string(),
  16. type: Joi.string(),
  17. /** Survey fields */
  18. steps: Joi.array().items(
  19. Joi.object({
  20. id: Joi.number(),
  21. type: Joi.string(),
  22. question: Joi.string(),
  23. // TODO: specify responses to be array or null later
  24. responses: Joi.any(),
  25. })
  26. ).required(),
  27. }),
  28. /** fields required before saving */
  29. required: ['steps'],
  30. validate(instance) {
  31. return this.properties.validate(instance)
  32. },
  33. }
  34. export { surveySchema }