|
2 | 2 | * Job Processor Service |
3 | 3 | */ |
4 | 4 |
|
5 | | -const Joi = require('@hapi/joi') |
| 5 | +const Joi = require('joi').extend(require('@joi/date')) |
6 | 6 | const logger = require('../common/logger') |
7 | 7 | const helper = require('../common/helper') |
8 | 8 | const constants = require('../common/constants') |
@@ -50,49 +50,54 @@ async function processCreate (message, transactionId) { |
50 | 50 | }) |
51 | 51 | } |
52 | 52 |
|
53 | | -processCreate.schema = { |
54 | | - message: Joi.object() |
55 | | - .keys({ |
56 | | - topic: Joi.string().required(), |
57 | | - originator: Joi.string().required(), |
58 | | - timestamp: Joi.date().required(), |
59 | | - 'mime-type': Joi.string().required(), |
60 | | - payload: Joi.object() |
61 | | - .keys({ |
62 | | - id: Joi.string().uuid().required(), |
63 | | - projectId: Joi.number().integer().required(), |
64 | | - externalId: Joi.string().allow(null), |
65 | | - description: Joi.stringAllowEmpty().allow(null), |
66 | | - title: Joi.title().required(), |
67 | | - startDate: Joi.date().allow(null), |
68 | | - duration: Joi.number().integer().min(1).allow(null), |
69 | | - numPositions: Joi.number().integer().min(1).required(), |
70 | | - resourceType: Joi.stringAllowEmpty().allow(null), |
71 | | - rateType: Joi.rateType().allow(null), |
72 | | - workload: Joi.workload().allow(null), |
73 | | - skills: Joi.array().items(Joi.string().uuid()).required(), |
74 | | - roles: Joi.array().items(Joi.string().uuid()).allow(null), |
75 | | - createdAt: Joi.date().required(), |
76 | | - createdBy: Joi.string().uuid().required(), |
77 | | - updatedAt: Joi.date().allow(null), |
78 | | - updatedBy: Joi.string().uuid().allow(null), |
79 | | - status: Joi.jobStatus().required(), |
80 | | - isApplicationPageActive: Joi.boolean().required(), |
81 | | - minSalary: Joi.number().integer().allow(null), |
82 | | - maxSalary: Joi.number().integer().allow(null), |
83 | | - hoursPerWeek: Joi.number().integer().allow(null), |
84 | | - jobLocation: Joi.stringAllowEmpty().allow(null), |
85 | | - jobTimezone: Joi.stringAllowEmpty().allow(null), |
86 | | - currency: Joi.stringAllowEmpty().allow(null), |
87 | | - roleIds: Joi.array() |
88 | | - .items(Joi.string().uuid().required()) |
89 | | - .allow(null) |
90 | | - }) |
91 | | - .required() |
92 | | - }) |
93 | | - .required(), |
94 | | - transactionId: Joi.string().required() |
95 | | -} |
| 53 | +processCreate.schema = Joi.object() |
| 54 | + .keys({ |
| 55 | + message: Joi.object() |
| 56 | + .keys({ |
| 57 | + topic: Joi.string().required(), |
| 58 | + originator: Joi.string().required(), |
| 59 | + timestamp: Joi.date().required(), |
| 60 | + 'mime-type': Joi.string().required(), |
| 61 | + payload: Joi.object() |
| 62 | + .keys({ |
| 63 | + id: Joi.string().uuid().required(), |
| 64 | + projectId: Joi.number().integer().required(), |
| 65 | + externalId: Joi.string().allow(null), |
| 66 | + description: Joi.stringAllowEmpty().allow(null), |
| 67 | + title: Joi.title().required(), |
| 68 | + startDate: Joi.date().format('YYYY-MM-DD').allow(null), |
| 69 | + duration: Joi.number().integer().min(1).allow(null), |
| 70 | + numPositions: Joi.number().integer().min(1).required(), |
| 71 | + resourceType: Joi.stringAllowEmpty().allow(null), |
| 72 | + rateType: Joi.rateType().allow(null), |
| 73 | + workload: Joi.workload().allow(null), |
| 74 | + skills: Joi.array().items(Joi.string().uuid()).required(), |
| 75 | + roles: Joi.array().items(Joi.string().uuid()).allow(null), |
| 76 | + createdAt: Joi.date().required(), |
| 77 | + createdBy: Joi.string().uuid().required(), |
| 78 | + updatedAt: Joi.date().allow(null), |
| 79 | + updatedBy: Joi.string().uuid().allow(null), |
| 80 | + status: Joi.jobStatus().required(), |
| 81 | + isApplicationPageActive: Joi.boolean().required(), |
| 82 | + minSalary: Joi.number().integer().allow(null), |
| 83 | + maxSalary: Joi.number().integer().allow(null), |
| 84 | + hoursPerWeek: Joi.number().integer().allow(null), |
| 85 | + jobLocation: Joi.stringAllowEmpty().allow(null), |
| 86 | + jobTimezone: Joi.stringAllowEmpty().allow(null), |
| 87 | + currency: Joi.stringAllowEmpty().allow(null), |
| 88 | + roleIds: Joi.array() |
| 89 | + .items(Joi.string().uuid().required()) |
| 90 | + .allow(null), |
| 91 | + showInHotList: Joi.boolean().default(false), |
| 92 | + featured: Joi.boolean().default(false), |
| 93 | + hotListExcerpt: Joi.stringAllowEmpty().default(''), |
| 94 | + jobTag: Joi.jobTag().default('') |
| 95 | + }) |
| 96 | + .required() |
| 97 | + }) |
| 98 | + .required(), |
| 99 | + transactionId: Joi.string().required() |
| 100 | + }) |
96 | 101 |
|
97 | 102 | /** |
98 | 103 | * Process update entity message |
|
0 commit comments