| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /** @module entities/profileSchema */
- import Joi from 'joi'
- import { allModules, responseSchema } from '../index.js'
-
- /**
- * profile schema object
- * uses the module system to use common fields
- * but sets fields with our validation types
- * @constructor
- */
- const profileSchema = {
- type: 'object',
- properties: Joi.object().keys({
- /** _baseRecord fields */
- createdAt: Joi.string(),
- _id: Joi.string(),
- lastUpdatedAt: Joi.string(),
- type: Joi.string(),
-
- /** our fields */
- email: Joi.string().email({
- minDomainSegments: 2,
- tlds: { allow: ['com', 'net'] },
- }),
-
- /** fields that should match backend service*/
- user_name: Joi.string(),
- user_id: Joi.number(),
- user_email: Joi.string(),
- image: Joi.any(),
- blurb: Joi.any(),
- profile_id: Joi.number(),
- profile_description: Joi.string().allow(null, ''),
- profile_media: Joi.array().items(Joi.string()),
- profile_languages: Joi.array().items(Joi.string()),
- profile_prefs: Joi.object(),
- responses: Joi.array().items(responseSchema), // response entity schema goes here
- reveal: Joi.array().items(),
- tags: Joi.array().items(),
- user_type: Joi.string(),
-
- /** tricky module system fields */
- ...allModules.location({
- street: Joi.string(),
- apt: Joi.string(),
- city: Joi.string(),
- state: Joi.string(),
- zip: Joi.number(),
- }),
- }),
- /** fields required before saving */
- required: [],
- validate(instance) {
- return this.properties.validate(instance)
- },
- }
-
- export { profileSchema }
|