-
Notifications
You must be signed in to change notification settings - Fork 4
/
joi-schema.js
74 lines (70 loc) · 2.04 KB
/
joi-schema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
'use strict'
const Joi = require('@hapi/joi')
const isObjectId = require('../../util/is-object-id')
const helpers = require('./helpers')
const personSchemaJoi = require('../../persons/schema/joi-schema')
const {
addressSchemaJoi,
hoursSchemaJoi,
dateUserActionSchemaJoi,
} = require('../../locations/schema/joi-schema')
const pregnancyCenterSchemaJoi = Joi.object({
__v: Joi.number().min(0),
_id: Joi.any()
.custom(isObjectId)
.allow(null),
address: addressSchemaJoi,
createdAt: Joi.date().iso(),
doNotList: Joi.boolean(),
email: Joi.string()
.email()
.allow(''),
hotlinePhoneNumber: Joi.string()
.trim()
.regex(/\+1([2-9][0-8][0-9])([2-9][0-9]{2})([0-9]{4})/)
.allow(''),
hours: hoursSchemaJoi,
inVerification: Joi.any()
.custom(isObjectId)
.allow(null),
prcName: Joi.string(),
notes: Joi.string().allow(''),
otherServices: Joi.string().allow(''),
outOfBusiness: Joi.boolean(),
phone: Joi.string()
.trim()
.regex(/\+1([2-9][0-8][0-9])([2-9][0-9]{2})([0-9]{4})/)
.allow(''),
primaryContactPerson: personSchemaJoi,
services: helpers.getPregnancyCenterServicesSchema(Joi.boolean()),
verifiedData: {
address: dateUserActionSchemaJoi,
email: dateUserActionSchemaJoi,
hotlinePhoneNumber: dateUserActionSchemaJoi,
hours: dateUserActionSchemaJoi,
prcName: dateUserActionSchemaJoi,
phone: dateUserActionSchemaJoi,
primaryContactPerson: dateUserActionSchemaJoi,
services: dateUserActionSchemaJoi,
website: dateUserActionSchemaJoi,
},
updated: {
address: dateUserActionSchemaJoi,
doNotList: dateUserActionSchemaJoi,
email: dateUserActionSchemaJoi,
hotlinePhoneNumber: dateUserActionSchemaJoi,
hours: dateUserActionSchemaJoi,
notes: dateUserActionSchemaJoi,
outOfBusiness: dateUserActionSchemaJoi,
phone: dateUserActionSchemaJoi,
prcName: dateUserActionSchemaJoi,
primaryContactPerson: dateUserActionSchemaJoi,
services: dateUserActionSchemaJoi,
website: dateUserActionSchemaJoi,
},
updatedAt: Joi.date().iso(),
website: Joi.string()
.uri()
.allow(''),
})
module.exports = pregnancyCenterSchemaJoi