-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation.js
More file actions
36 lines (36 loc) · 1.02 KB
/
Copy pathvalidation.js
File metadata and controls
36 lines (36 loc) · 1.02 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
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Joi = require("joi");
const mongoose_1 = require("mongoose");
/**
* @export
* @class Validation
*/
class Validation {
/**
* Creates an instance of Schema.
* @memberof JoiSchema
*/
constructor() {
/**
* @static
* @type {string}
* @memberof JoiSchema
*/
this.messageObjectId = 'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters';
this.customJoi = Joi.extend((joi) => ({
type: 'objectId',
base: joi.string(),
validate(value, helpers) {
if (!mongoose_1.Types.ObjectId.isValid(value)) {
return this.createError('objectId.base', {
value
}, helpers);
}
return value; // Keep the value as it was
}
}));
}
}
exports.default = Validation;
//# sourceMappingURL=validation.js.map