-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschemas.js
More file actions
49 lines (47 loc) · 1.58 KB
/
schemas.js
File metadata and controls
49 lines (47 loc) · 1.58 KB
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
const Joi = require('joi');
module.exports.ticketSchema = Joi.object({
swrNum: Joi.string(),
dateSubmitted: Joi.date()
.default(Date.now())
.required(),
originator: Joi.string()
.required(),
captured: Joi.string()
.required(),
capturedSlot: Joi
.when('captured', { is: 'SavedIC#', then: Joi.number().max(350).min(1).required() })
.when('captured', { is: 'Snapped', then: Joi.number().max(5).min(1).required() })
,
title: Joi.string()
.required(),
description: Joi.string()
.required(),
impactedTraining: Joi.string()
.required(),
priority: Joi.number()
.required(),
system: Joi.string()
.required(),
assignedTo: Joi
.when('status', { not: 'Unassigned', then: Joi.string().required() }),
status: Joi.string().default('Unassigned'),
deferredID: Joi.string().allow(''),
workPerformed: Joi.string()
.when('status', { is: 'Closed', then: Joi.string().required() })
.when('status', { not: 'Closed', then: Joi.string().allow('') },),
validatedBy: Joi.string(),
// .when('status', {
// is: 'Closed',
// then: Joi.string().required()
// }),
dateClosed: Joi.date()
.when('status', {
is: 'Closed', then: Joi.date().required()
}),
}).required()
.options({ allowUnknown: true });
module.exports.userSchema = Joi.object({
email: Joi.string().required(),
username: Joi.string().required(),
password: Joi.string().required(),
}).required()