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

profile.schema.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /** @module entities/profileSchema */
  2. import Joi from 'joi'
  3. import { allModules, responseSchema } from '../index.js'
  4. /**
  5. * profile schema object
  6. * uses the module system to use common fields
  7. * but sets fields with our validation types
  8. * @constructor
  9. */
  10. const profileSchema = {
  11. type: 'object',
  12. properties: Joi.object().keys({
  13. /** _baseRecord fields */
  14. createdAt: Joi.string(),
  15. _id: Joi.string(),
  16. lastUpdatedAt: Joi.string(),
  17. type: Joi.string(),
  18. /** our fields */
  19. email: Joi.string().email({
  20. minDomainSegments: 2,
  21. tlds: { allow: ['com', 'net'] },
  22. }),
  23. /** fields that should match backend service*/
  24. user_name: Joi.string(),
  25. user_id: Joi.number(),
  26. user_email: Joi.string(),
  27. image: Joi.any(),
  28. blurb: Joi.any(),
  29. profile_id: Joi.number(),
  30. profile_description: Joi.string().allow(null, ''),
  31. profile_media: Joi.array().items(Joi.string()),
  32. profile_languages: Joi.array().items(Joi.string()),
  33. profile_prefs: Joi.object(),
  34. responses: Joi.array().items(responseSchema), // response entity schema goes here
  35. reveal: Joi.array().items(),
  36. tags: Joi.array().items(),
  37. user_type: Joi.string(),
  38. /** tricky module system fields */
  39. ...allModules.location({
  40. street: Joi.string(),
  41. apt: Joi.string(),
  42. city: Joi.string(),
  43. state: Joi.string(),
  44. zip: Joi.number(),
  45. }),
  46. }),
  47. /** fields required before saving */
  48. required: [],
  49. validate(instance) {
  50. return this.properties.validate(instance)
  51. },
  52. }
  53. export { profileSchema }