@tellescope/validation 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/validation.d.ts +168 -143
- package/lib/cjs/validation.d.ts.map +1 -1
- package/lib/cjs/validation.js +971 -699
- package/lib/cjs/validation.js.map +1 -1
- package/lib/esm/validation.d.ts +168 -143
- package/lib/esm/validation.d.ts.map +1 -1
- package/lib/esm/validation.js +952 -664
- package/lib/esm/validation.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/validation.ts +946 -664
package/lib/cjs/validation.js
CHANGED
|
@@ -10,14 +10,26 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
13
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
26
|
};
|
|
16
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
28
|
+
exports.mongoIdStringRequired = exports.listOfMongoIdValidator = exports.mongoIdOptional = exports.mongoIdRequired = exports.nullValidator = exports.buildMongoIdStringValidator = exports.mongoIdValidator = exports.escapeMongoId = exports.booleanValidatorOptional = exports.booleanValidator = exports.booleanValidatorBuilder = exports.listOfObjectAnyFieldsAnyValuesValidator = exports.listOfStringsValidatorEmptyOk = exports.listOfStringsValidatorOptionalOrEmptyOk = exports.listOfStringsValidator = exports.listValidatorOptionalOrEmptyOk = exports.listValidatorEmptyOk = exports.listValidator = exports.SMSMessageValidator = exports.stringValidator25000EmptyOkay = exports.stringValidator25000 = exports.stringValidator5000Optional = exports.stringValidator5000EmptyOkay = exports.stringValidator5000 = exports.stringValidator1000 = exports.stringValidator250 = exports.stringValidator100 = exports.stringValidatorOptional = exports.stringValidator = exports.escapeString = exports.objectAnyFieldsAnyValuesValidator = exports.objectAnyFieldsValidator = exports.listOfObjectsValidator = exports.objectValidator = exports.listValidatorOld = exports.objectValidatorOld = exports.convertCommands = exports.convertCommand = exports.filterCommandsValidator = exports.orValidator = exports.binaryOrValidator = exports.fieldsToValidationOld = exports.build_validator = exports.MAX_FILE_SIZE = exports.isURL = exports.isMimeType = exports.isMongoId = exports.isMobilePhone = exports.isEmail = exports.isDate = void 0;
|
|
29
|
+
exports.formResponseValidator = exports.formResponseAnswerValidator = exports.INTERNAL_NAME_TO_DISPLAY_FIELD = exports.ENDUSER_FIELD_TYPES = exports.RESERVED_INTAKE_FIELDS = exports.idStringToDateValidator = exports.numberToDateValidator = exports.rejectionWithMessage = exports.indexableNumberValidator = exports.indexableValidator = exports.validateIndexable = exports.emailEncodingValidator = exports.journeyStatesValidator = exports.journeyStateValidator = exports.journeyStatePriorityValidator = exports.updateOptionsValidator = exports.preferenceValidator = exports.fieldsValidator = exports.FORM_FIELD_VALIDATORS_BY_TYPE = exports.formFieldTypeValidator = exports.FORM_FIELD_TYPES = exports.signatureResponseValidator = exports.fileResponseValidator = exports.subdomainValidator = exports.safeBase64Validator = exports.urlValidator = exports.fileTypeValidator = exports.phoneValidatorOptional = exports.phoneValidator = exports.escape_phone_number = exports.journeysValidator = exports.exactMatchListValidator = exports.exactMatchValidatorOptional = exports.exactMatchValidator = exports.dateValidatorOptional = exports.dateValidator = exports.fileSizeValidator = exports.numberValidatorOptional = exports.numberValidator = exports.nonNegNumberValidator = exports.numberValidatorBuilder = exports.emailValidatorEmptyOkay = exports.emailValidatorOptional = exports.emailValidator = exports.nameValidator = exports.escape_name = exports.first_letter_capitalized = exports.listOfMongoIdStringValidatorEmptyOk = exports.listOfMongoIdStringValidator = exports.mongoIdStringOptional = void 0;
|
|
30
|
+
exports.sendFormChannelValidator = exports.SEND_FORM_CHANNELS = exports.listOfAutomationConditionsValidator = exports.automationConditionValidator = exports.automationEventsValidator = exports.automationEventValidator = exports.cancelConditionsValidatorOptional = exports.cancelConditionsValidator = exports.listOfCalendarEventRemindersValidator = exports.calendarEventReminderValidator = exports.messageTemplateModeValidator = exports.MESSAGE_TEMPLATE_MODES = exports.automationActionTypeValidator = exports.AUTOMATION_ACTIONS = exports.automationEventTypeValidator = exports.AUTOMATION_EVENTS = exports.automatedActionStatusValidator = exports.AUTOMATION_ENDUSER_STATUS = exports.chatRoomUserInfoValidator = exports.meetingDisplayInfoValidator = exports.userDisplayInfoValidator = exports.meetingsListValidator = exports.listOfChatAttachmentsValidator = exports.chatAttachmentValidator = exports.listOfUserIndentitiesValidator = exports.userIdentityValidator = exports.meetingInfoValidator = exports.listOfAttendeesValidator = exports.attendeeValidator = exports.attendeeInfoValidator = exports.listOfDisplayNameInfo = exports.sessionTypeValidator = exports.WebhookSubscriptionValidator = exports.UnitOfTimeValidator = exports.UNITS_OF_TIME = exports.CUDValidator = exports.CUDStringValidator = exports.CUD = exports.meetingStatusValidator = exports.MEETING_STATUSES = exports.messageTemplateTypeValidator = exports.MESSAGE_TEMPLATE_TYPES = exports.accountTypeValidator = exports.ACCOUNT_TYPES = exports.chatRoomTypeValidator = exports.CHAT_ROOM_TYPES = exports.listOfFormFieldsValidator = exports.formFieldValidator = exports.intakePhoneValidator = exports.formResponsesValidator = void 0;
|
|
31
|
+
exports.availabilityBlocksValidator = exports.availabilityBlockValidator = exports.stateCredentialsValidator = exports.stateCredentialValidator = exports.stateValidator = exports.VALID_STATES = exports.enduserFormResponsesForEventValidator = exports.enduserFormResponseForEventValidator = exports.enduserTasksForEventValidator = exports.enduserTaskForEventValidator = exports.portalTypeValidator = exports.PORTAL_BLOCK_TYPES = exports.portalBlocksValidator = exports.portalBlockValidator = exports.portalPageValidator = exports.PORTAL_PAGES = exports.organizationAccessValidator = exports.databaseRecordValuesValidator = exports.databaseRecordValueValidator = exports.databaseFieldsValidator = exports.databaseFieldValidator = exports.is_database_record_field_type = exports.databaseRecordFieldTypeValidator = exports.DATABASE_RECORD_FIELD_TYPES = exports.blocksValidator = exports.is_block_type = exports.blockTypeValidator = exports.BLOCK_TYPES = exports.blockValidator = exports.formFieldOptionsValidator = exports.integrationAuthenticationsValidator = exports.flowchartUIValidator = exports.passwordValidator = exports.managedContentRecordTypeValidator = exports.MANAGED_CONTENT_RECORD_TYPES = exports.organizationThemeValidator = exports.portalSettingsValidator = exports.previousFormFieldsValidator = exports.previousFormFieldValidator = exports.FHIRObservationValueValidator = exports.FHIRObservationStatusCodeValidator = exports.FHIR_OBSERVATION_STATUS_CODES = exports.FHIRObservationCategoryValidator = exports.notificationPreferencesValidator = exports.notificationPreferenceValidator = exports.searchOptionsValidator = exports.listOfRelatedRecordsValidator = exports.relatedRecordValidator = exports.automationActionValidator = exports.sendFormChannelValidatorOptional = void 0;
|
|
32
|
+
exports.timezoneValidator = exports.weeklyAvailabilitiesValidator = exports.weeklyAvailabilityValidator = void 0;
|
|
21
33
|
var types_models_1 = require("@tellescope/types-models");
|
|
22
34
|
var validator_1 = __importDefault(require("validator"));
|
|
23
35
|
exports.isDate = validator_1.default.isDate, exports.isEmail = validator_1.default.isEmail, exports.isMobilePhone = validator_1.default.isMobilePhone, exports.isMongoId = validator_1.default.isMongoId, exports.isMimeType = validator_1.default.isMimeType, exports.isURL = validator_1.default.isURL;
|
|
@@ -25,6 +37,11 @@ exports.isDate = validator_1.default.isDate, exports.isEmail = validator_1.defau
|
|
|
25
37
|
// BUSINESS_TYPE,
|
|
26
38
|
// } from "@tellescope/constants"
|
|
27
39
|
var utilities_1 = require("@tellescope/utilities");
|
|
40
|
+
var EXAMPLE_OBJECT_ID = '60398b0231a295e64f084fd9';
|
|
41
|
+
var getTypeString = function () { return "string"; };
|
|
42
|
+
var getTypeNumber = function () { return "number"; };
|
|
43
|
+
var getExampleString = function () { return 'example string'; };
|
|
44
|
+
var getExampleObjectId = function () { return EXAMPLE_OBJECT_ID; };
|
|
28
45
|
exports.MAX_FILE_SIZE = 25000000; // 25 megabytes in bytes
|
|
29
46
|
var DEFAULT_MAX_LENGTH = 5000;
|
|
30
47
|
var build_validator = function (escapeFunction, options) {
|
|
@@ -109,14 +126,14 @@ var build_validator = function (escapeFunction, options) {
|
|
|
109
126
|
};
|
|
110
127
|
};
|
|
111
128
|
exports.build_validator = build_validator;
|
|
112
|
-
var
|
|
129
|
+
var fieldsToValidationOld = function (fs) {
|
|
113
130
|
var validation = {};
|
|
114
131
|
for (var f in fs) {
|
|
115
|
-
validation[f] = fs[f].validator({ isOptional: !fs[f].required });
|
|
132
|
+
validation[f] = fs[f].validator.validate({ isOptional: !fs[f].required });
|
|
116
133
|
}
|
|
117
134
|
return validation;
|
|
118
135
|
};
|
|
119
|
-
exports.
|
|
136
|
+
exports.fieldsToValidationOld = fieldsToValidationOld;
|
|
120
137
|
/********************************* VALIDATORS *********************************/
|
|
121
138
|
var optionsWithDefaults = function (options) {
|
|
122
139
|
if (options === void 0) { options = {}; }
|
|
@@ -146,21 +163,25 @@ var binaryOrValidator = function (f1, f2) { return function (o) {
|
|
|
146
163
|
}, __assign(__assign({}, o), { listOf: false }));
|
|
147
164
|
}; };
|
|
148
165
|
exports.binaryOrValidator = binaryOrValidator;
|
|
149
|
-
var orValidator = function (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
var
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
166
|
+
var orValidator = function (validators) { return ({
|
|
167
|
+
validate: function (o) {
|
|
168
|
+
if (o === void 0) { o = {}; }
|
|
169
|
+
return (0, exports.build_validator)(function (value) {
|
|
170
|
+
for (var field in validators) {
|
|
171
|
+
var escape_1 = validators[field];
|
|
172
|
+
try {
|
|
173
|
+
return escape_1.validate()(value);
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
159
178
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
},
|
|
163
|
-
|
|
179
|
+
throw "Value does not match any of the expected options";
|
|
180
|
+
}, __assign(__assign({}, o), { listOf: false }));
|
|
181
|
+
},
|
|
182
|
+
getExample: function () { return Object.values(validators)[0].getExample(); },
|
|
183
|
+
getType: function () { return [Object.values(validators).map(function (v) { return v.getType(); })]; }
|
|
184
|
+
}); };
|
|
164
185
|
exports.orValidator = orValidator;
|
|
165
186
|
var filterCommandsValidator = function (o) {
|
|
166
187
|
if (o === void 0) { o = {}; }
|
|
@@ -222,7 +243,7 @@ var convertCommands = function (operators) {
|
|
|
222
243
|
return filterOperators;
|
|
223
244
|
};
|
|
224
245
|
exports.convertCommands = convertCommands;
|
|
225
|
-
var
|
|
246
|
+
var objectValidatorOld = function (i, objectOptions) {
|
|
226
247
|
if (objectOptions === void 0) { objectOptions = { emptyOk: true }; }
|
|
227
248
|
return function (o) {
|
|
228
249
|
if (o === void 0) { o = {}; }
|
|
@@ -259,72 +280,138 @@ var objectValidator = function (i, objectOptions) {
|
|
|
259
280
|
}, __assign(__assign({}, o), { isObject: true, listOf: false }));
|
|
260
281
|
};
|
|
261
282
|
};
|
|
283
|
+
exports.objectValidatorOld = objectValidatorOld;
|
|
284
|
+
var listValidatorOld = function (b) { return function (o) { return (0, exports.build_validator)(b, __assign(__assign({}, o), { listOf: true })); }; };
|
|
285
|
+
exports.listValidatorOld = listValidatorOld;
|
|
286
|
+
var exampleObject = function (fields) {
|
|
287
|
+
var examples = {};
|
|
288
|
+
for (var field in fields) {
|
|
289
|
+
examples[field] = fields[field].getExample();
|
|
290
|
+
}
|
|
291
|
+
return examples;
|
|
292
|
+
};
|
|
293
|
+
var typeObject = function (fields) {
|
|
294
|
+
var types = {};
|
|
295
|
+
for (var field in fields) {
|
|
296
|
+
types[field] = fields[field].getType();
|
|
297
|
+
}
|
|
298
|
+
return types;
|
|
299
|
+
};
|
|
300
|
+
var objectValidator = function (i, objectOptions) {
|
|
301
|
+
if (objectOptions === void 0) { objectOptions = { emptyOk: true }; }
|
|
302
|
+
return ({
|
|
303
|
+
validate: function (o) {
|
|
304
|
+
if (o === void 0) { o = {}; }
|
|
305
|
+
return (0, exports.build_validator)(function (object) {
|
|
306
|
+
var _a;
|
|
307
|
+
var emptyOk = (_a = objectOptions.emptyOk) !== null && _a !== void 0 ? _a : true;
|
|
308
|
+
var validated = {};
|
|
309
|
+
if (!(0, utilities_1.is_object)(object)) {
|
|
310
|
+
throw new Error("Expected a non-null object by got ".concat(object));
|
|
311
|
+
}
|
|
312
|
+
if (!emptyOk && (0, utilities_1.object_is_empty)(object)) {
|
|
313
|
+
throw new Error("Expected a non-empty object");
|
|
314
|
+
}
|
|
315
|
+
// don't throw on unrecognized fields, just ignore/don't validate them
|
|
316
|
+
if (objectOptions.throwOnUnrecognizedField) {
|
|
317
|
+
var unrecognizedFields = [];
|
|
318
|
+
for (var field in object) {
|
|
319
|
+
if (!i[field]) {
|
|
320
|
+
unrecognizedFields.push(field);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (unrecognizedFields.length > 0) {
|
|
324
|
+
throw new Error("Got unexpected field(s) [".concat(unrecognizedFields.join(', '), "]"));
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
for (var field in i) {
|
|
328
|
+
var value = object[field];
|
|
329
|
+
var escaped = i[field].validate()(value); // may be required
|
|
330
|
+
if (escaped === undefined)
|
|
331
|
+
continue;
|
|
332
|
+
validated[field] = escaped;
|
|
333
|
+
}
|
|
334
|
+
return validated;
|
|
335
|
+
}, __assign(__assign({}, o), { isObject: true, listOf: false, isOptional: !!objectOptions.isOptional || o.isOptional }));
|
|
336
|
+
},
|
|
337
|
+
getExample: function () { return exampleObject(i); },
|
|
338
|
+
getType: function () { return typeObject(i); },
|
|
339
|
+
});
|
|
340
|
+
};
|
|
262
341
|
exports.objectValidator = objectValidator;
|
|
263
342
|
var listOfObjectsValidator = function (i, objectOptions) {
|
|
264
343
|
if (objectOptions === void 0) { objectOptions = { emptyOk: true }; }
|
|
265
|
-
return
|
|
344
|
+
return ({
|
|
345
|
+
validate: function (o) {
|
|
346
|
+
if (o === void 0) { o = {}; }
|
|
347
|
+
return (0, exports.build_validator)(function (object) {
|
|
348
|
+
var emptyOk = !!objectOptions.emptyOk || o.emptyListOk;
|
|
349
|
+
var validated = {};
|
|
350
|
+
if (!(0, utilities_1.is_object)(object)) {
|
|
351
|
+
throw new Error("Expected a non-null object by got ".concat(object));
|
|
352
|
+
}
|
|
353
|
+
if (!emptyOk && (0, utilities_1.object_is_empty)(object)) {
|
|
354
|
+
throw new Error("Expected a non-empty object");
|
|
355
|
+
}
|
|
356
|
+
// don't throw on unrecognized fields, just ignore/don't validate them
|
|
357
|
+
// const unrecognizedFields = []
|
|
358
|
+
// for (const field in object) {
|
|
359
|
+
// if (!(i as Indexable)[field]) {
|
|
360
|
+
// unrecognizedFields.push(field)
|
|
361
|
+
// }
|
|
362
|
+
// }
|
|
363
|
+
// if (unrecognizedFields.length > 0) {
|
|
364
|
+
// throw new Error(`Got unexpected field(s) [${unrecognizedFields.join(', ')}]`)
|
|
365
|
+
// }
|
|
366
|
+
for (var field in i) {
|
|
367
|
+
var value = object[field];
|
|
368
|
+
var escaped = i[field].validate()(value); // may be required
|
|
369
|
+
if (escaped === undefined)
|
|
370
|
+
continue;
|
|
371
|
+
validated[field] = escaped;
|
|
372
|
+
}
|
|
373
|
+
return validated;
|
|
374
|
+
}, __assign(__assign({}, o), { isObject: true, listOf: true, emptyListOk: !!objectOptions.emptyOk || o.emptyListOk }));
|
|
375
|
+
},
|
|
376
|
+
getExample: function () { return [exampleObject(i)]; },
|
|
377
|
+
getType: function () { return [typeObject(i)]; } // don't forget list
|
|
378
|
+
});
|
|
379
|
+
};
|
|
380
|
+
exports.listOfObjectsValidator = listOfObjectsValidator;
|
|
381
|
+
var objectAnyFieldsValidator = function (valueValidator) { return ({
|
|
382
|
+
validate: function (o) {
|
|
266
383
|
if (o === void 0) { o = {}; }
|
|
267
384
|
return (0, exports.build_validator)(function (object) {
|
|
268
|
-
var emptyOk = !!objectOptions.emptyOk || o.emptyListOk;
|
|
269
|
-
var validated = {};
|
|
270
385
|
if (!(0, utilities_1.is_object)(object)) {
|
|
271
|
-
throw new Error("Expected a non-null object by got "
|
|
272
|
-
}
|
|
273
|
-
if (!emptyOk && (0, utilities_1.object_is_empty)(object)) {
|
|
274
|
-
throw new Error("Expected a non-empty object");
|
|
275
|
-
}
|
|
276
|
-
// don't throw on unrecognized fields, just ignore/don't validate them
|
|
277
|
-
// const unrecognizedFields = []
|
|
278
|
-
// for (const field in object) {
|
|
279
|
-
// if (!(i as Indexable)[field]) {
|
|
280
|
-
// unrecognizedFields.push(field)
|
|
281
|
-
// }
|
|
282
|
-
// }
|
|
283
|
-
// if (unrecognizedFields.length > 0) {
|
|
284
|
-
// throw new Error(`Got unexpected field(s) [${unrecognizedFields.join(', ')}]`)
|
|
285
|
-
// }
|
|
286
|
-
for (var field in i) {
|
|
287
|
-
var value = object[field];
|
|
288
|
-
var escaped = i[field](value); // may be required
|
|
289
|
-
if (escaped === undefined)
|
|
290
|
-
continue;
|
|
291
|
-
validated[field] = escaped;
|
|
292
|
-
}
|
|
293
|
-
return validated;
|
|
294
|
-
}, __assign(__assign({}, o), { isObject: true, listOf: true, emptyListOk: !!objectOptions.emptyOk || o.emptyListOk }));
|
|
295
|
-
};
|
|
296
|
-
};
|
|
297
|
-
exports.listOfObjectsValidator = listOfObjectsValidator;
|
|
298
|
-
var objectAnyFieldsValidator = function (valueValidator) { return function (o) {
|
|
299
|
-
if (o === void 0) { o = {}; }
|
|
300
|
-
return (0, exports.build_validator)(function (object) {
|
|
301
|
-
if (!(0, utilities_1.is_object)(object)) {
|
|
302
|
-
throw new Error("Expected a non-null object by got ${object}");
|
|
303
|
-
}
|
|
304
|
-
var validated = {};
|
|
305
|
-
for (var field in object) {
|
|
306
|
-
if (valueValidator) {
|
|
307
|
-
validated[field] = valueValidator(object[field]);
|
|
308
|
-
}
|
|
309
|
-
else if (typeof object[field] === 'number') {
|
|
310
|
-
validated[field] = (0, exports.numberValidator)(object[field]);
|
|
311
|
-
}
|
|
312
|
-
else if (typeof object[field] === 'string') {
|
|
313
|
-
validated[field] = (0, exports.stringValidator)(object[field]);
|
|
386
|
+
throw new Error("Expected a non-null object by got ${object}");
|
|
314
387
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
388
|
+
var validated = {};
|
|
389
|
+
for (var field in object) {
|
|
319
390
|
if (valueValidator) {
|
|
320
|
-
|
|
391
|
+
validated[field] = valueValidator.validate()(object[field]);
|
|
392
|
+
}
|
|
393
|
+
else if (typeof object[field] === 'number') {
|
|
394
|
+
validated[field] = exports.numberValidator.validate()(object[field]);
|
|
395
|
+
}
|
|
396
|
+
else if (typeof object[field] === 'string') {
|
|
397
|
+
validated[field] = exports.stringValidator.validate()(object[field]);
|
|
398
|
+
}
|
|
399
|
+
else if (object[field] === null) {
|
|
400
|
+
validated[field] = null;
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
if (valueValidator) {
|
|
404
|
+
throw new Error("Field ".concat(field, " is not a string or number"));
|
|
405
|
+
}
|
|
406
|
+
validated[field] = object[field];
|
|
321
407
|
}
|
|
322
|
-
validated[field] = object[field];
|
|
323
408
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
},
|
|
327
|
-
}; }
|
|
409
|
+
return validated;
|
|
410
|
+
}, __assign(__assign({}, o), { isObject: true, listOf: false }));
|
|
411
|
+
},
|
|
412
|
+
getExample: function () { var _a, _b; return "{ \"key\": ".concat((_b = (_a = valueValidator === null || valueValidator === void 0 ? void 0 : valueValidator.getExample) === null || _a === void 0 ? void 0 : _a.call(valueValidator)) !== null && _b !== void 0 ? _b : '"value"', " }"); },
|
|
413
|
+
getType: function () { var _a, _b; return "{ \"key\": ".concat((_b = (_a = valueValidator === null || valueValidator === void 0 ? void 0 : valueValidator.getType) === null || _a === void 0 ? void 0 : _a.call(valueValidator)) !== null && _b !== void 0 ? _b : 'string', " }"); },
|
|
414
|
+
}); };
|
|
328
415
|
exports.objectAnyFieldsValidator = objectAnyFieldsValidator;
|
|
329
416
|
exports.objectAnyFieldsAnyValuesValidator = (0, exports.objectAnyFieldsValidator)();
|
|
330
417
|
var escapeString = function (o) {
|
|
@@ -342,63 +429,138 @@ var escapeString = function (o) {
|
|
|
342
429
|
};
|
|
343
430
|
};
|
|
344
431
|
exports.escapeString = escapeString;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
432
|
+
exports.stringValidator = {
|
|
433
|
+
validate: function (o) {
|
|
434
|
+
var _a;
|
|
435
|
+
if (o === void 0) { o = {}; }
|
|
436
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: (_a = o.maxLength) !== null && _a !== void 0 ? _a : 1000, listOf: false }));
|
|
437
|
+
},
|
|
438
|
+
getExample: getExampleString,
|
|
439
|
+
getType: getTypeString,
|
|
349
440
|
};
|
|
350
|
-
exports.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
441
|
+
exports.stringValidatorOptional = {
|
|
442
|
+
validate: function (o) {
|
|
443
|
+
var _a;
|
|
444
|
+
if (o === void 0) { o = {}; }
|
|
445
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: (_a = o.maxLength) !== null && _a !== void 0 ? _a : 1000, listOf: false, isOptional: true }));
|
|
446
|
+
},
|
|
447
|
+
getExample: getExampleString,
|
|
448
|
+
getType: getTypeString,
|
|
354
449
|
};
|
|
355
|
-
exports.stringValidator100 =
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
450
|
+
exports.stringValidator100 = {
|
|
451
|
+
validate: function (o) {
|
|
452
|
+
if (o === void 0) { o = {}; }
|
|
453
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: 100, listOf: false }));
|
|
454
|
+
},
|
|
455
|
+
getExample: function () { return 'example string'; },
|
|
456
|
+
getType: function () { return 'string'; }
|
|
359
457
|
};
|
|
360
|
-
exports.stringValidator250 =
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
458
|
+
exports.stringValidator250 = {
|
|
459
|
+
validate: function (o) {
|
|
460
|
+
if (o === void 0) { o = {}; }
|
|
461
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: 250, listOf: false }));
|
|
462
|
+
},
|
|
463
|
+
getExample: getExampleString,
|
|
464
|
+
getType: getTypeString,
|
|
364
465
|
};
|
|
365
|
-
exports.stringValidator1000 =
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
466
|
+
exports.stringValidator1000 = {
|
|
467
|
+
validate: function (o) {
|
|
468
|
+
if (o === void 0) { o = {}; }
|
|
469
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: 1000, listOf: false }));
|
|
470
|
+
},
|
|
471
|
+
getExample: getExampleString,
|
|
472
|
+
getType: getTypeString,
|
|
369
473
|
};
|
|
370
|
-
exports.stringValidator5000 =
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
474
|
+
exports.stringValidator5000 = {
|
|
475
|
+
validate: function (o) {
|
|
476
|
+
if (o === void 0) { o = {}; }
|
|
477
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: 5000, listOf: false }));
|
|
478
|
+
},
|
|
479
|
+
getExample: getExampleString,
|
|
480
|
+
getType: getTypeString,
|
|
374
481
|
};
|
|
375
|
-
exports.
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
482
|
+
exports.stringValidator5000EmptyOkay = {
|
|
483
|
+
validate: function (o) {
|
|
484
|
+
if (o === void 0) { o = {}; }
|
|
485
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: 5000, listOf: false, emptyStringOk: true }));
|
|
486
|
+
},
|
|
487
|
+
getExample: getExampleString,
|
|
488
|
+
getType: getTypeString,
|
|
489
|
+
};
|
|
490
|
+
exports.stringValidator5000Optional = {
|
|
491
|
+
validate: function (o) {
|
|
492
|
+
if (o === void 0) { o = {}; }
|
|
493
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: 5000, listOf: false, isOptional: true, emptyStringOk: true }));
|
|
494
|
+
},
|
|
495
|
+
getExample: getExampleString,
|
|
496
|
+
getType: getTypeString,
|
|
497
|
+
};
|
|
498
|
+
exports.stringValidator25000 = {
|
|
499
|
+
validate: function (o) {
|
|
500
|
+
if (o === void 0) { o = {}; }
|
|
501
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: 25000, listOf: false }));
|
|
502
|
+
},
|
|
503
|
+
getExample: getExampleString,
|
|
504
|
+
getType: getTypeString,
|
|
379
505
|
};
|
|
380
|
-
exports.
|
|
381
|
-
|
|
506
|
+
exports.stringValidator25000EmptyOkay = {
|
|
507
|
+
validate: function (o) {
|
|
508
|
+
if (o === void 0) { o = {}; }
|
|
509
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: 25000, listOf: false, emptyStringOk: true }));
|
|
510
|
+
},
|
|
511
|
+
getExample: getExampleString,
|
|
512
|
+
getType: getTypeString,
|
|
513
|
+
};
|
|
514
|
+
exports.SMSMessageValidator = {
|
|
515
|
+
validate: function (o) {
|
|
516
|
+
if (o === void 0) { o = {}; }
|
|
517
|
+
return (0, exports.build_validator)((0, exports.escapeString)(o), __assign(__assign({}, o), { maxLength: 630, listOf: false }));
|
|
518
|
+
},
|
|
519
|
+
getExample: getExampleString,
|
|
520
|
+
getType: getTypeString,
|
|
521
|
+
};
|
|
522
|
+
var listValidator = function (b, o) { return ({
|
|
523
|
+
validate: function (o) { return (0, exports.build_validator)(b.validate(o), __assign(__assign({}, o), { listOf: true })); },
|
|
524
|
+
getExample: function () { return [b.getExample()]; },
|
|
525
|
+
getType: function () { return [b.getExample()]; },
|
|
526
|
+
}); };
|
|
382
527
|
exports.listValidator = listValidator;
|
|
383
|
-
var listValidatorEmptyOk = function (b
|
|
528
|
+
var listValidatorEmptyOk = function (b, o) { return ({
|
|
529
|
+
validate: function (o) { return (0, exports.build_validator)(b.validate(o), __assign(__assign({}, o), { listOf: true, emptyListOk: true })); },
|
|
530
|
+
getExample: function () { return [b.getExample()]; },
|
|
531
|
+
getType: function () { return [b.getExample()]; },
|
|
532
|
+
}); };
|
|
384
533
|
exports.listValidatorEmptyOk = listValidatorEmptyOk;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
return boolean
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
534
|
+
var listValidatorOptionalOrEmptyOk = function (b, o) { return ({
|
|
535
|
+
validate: function (o) { return (0, exports.build_validator)(b.validate(o), __assign(__assign({}, o), { listOf: true, emptyListOk: true, isOptional: true })); },
|
|
536
|
+
getExample: function () { return [b.getExample()]; },
|
|
537
|
+
getType: function () { return [b.getExample()]; },
|
|
538
|
+
}); };
|
|
539
|
+
exports.listValidatorOptionalOrEmptyOk = listValidatorOptionalOrEmptyOk;
|
|
540
|
+
exports.listOfStringsValidator = (0, exports.listValidator)(exports.stringValidator);
|
|
541
|
+
exports.listOfStringsValidatorOptionalOrEmptyOk = (0, exports.listValidatorOptionalOrEmptyOk)(exports.stringValidator);
|
|
542
|
+
exports.listOfStringsValidatorEmptyOk = (0, exports.listValidatorEmptyOk)(exports.stringValidator);
|
|
543
|
+
exports.listOfObjectAnyFieldsAnyValuesValidator = (0, exports.listValidator)(exports.objectAnyFieldsAnyValuesValidator);
|
|
544
|
+
var booleanValidatorBuilder = function (defaults) { return ({
|
|
545
|
+
validate: function (options) {
|
|
546
|
+
if (options === void 0) { options = {}; }
|
|
547
|
+
return (0, exports.build_validator)(function (boolean) {
|
|
548
|
+
if (boolean === 'true')
|
|
549
|
+
return true;
|
|
550
|
+
if (boolean === 'false')
|
|
551
|
+
return false;
|
|
552
|
+
if (typeof boolean !== 'boolean') {
|
|
553
|
+
throw new Error(options.errorMessage || "Invalid boolean");
|
|
554
|
+
}
|
|
555
|
+
return boolean;
|
|
556
|
+
}, __assign(__assign(__assign({}, defaults), options), { isBoolean: true, listOf: false }));
|
|
557
|
+
},
|
|
558
|
+
getExample: function () { return "false"; },
|
|
559
|
+
getType: function () { return "boolean"; },
|
|
560
|
+
}); };
|
|
561
|
+
exports.booleanValidatorBuilder = booleanValidatorBuilder;
|
|
562
|
+
exports.booleanValidator = (0, exports.booleanValidatorBuilder)({});
|
|
563
|
+
exports.booleanValidatorOptional = (0, exports.booleanValidatorBuilder)({ isOptional: true });
|
|
402
564
|
var escapeMongoId = function (mongoId) {
|
|
403
565
|
if (typeof mongoId !== 'string')
|
|
404
566
|
throw new Error('Expecting string id');
|
|
@@ -408,16 +570,23 @@ var escapeMongoId = function (mongoId) {
|
|
|
408
570
|
return mongoId;
|
|
409
571
|
};
|
|
410
572
|
exports.escapeMongoId = escapeMongoId;
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
return (0, exports.build_validator)(exports.escapeMongoId, __assign(__assign({}, optionsWithDefaults(o)), { maxLength: 100, listOf: false }));
|
|
573
|
+
exports.mongoIdValidator = {
|
|
574
|
+
validate: function (o) {
|
|
575
|
+
if (o === void 0) { o = {}; }
|
|
576
|
+
return (0, exports.build_validator)(function (s) { return (0, utilities_1.to_object_id)((0, exports.escapeMongoId)(s)); }, __assign(__assign({}, optionsWithDefaults(o)), { maxLength: 100, listOf: false }));
|
|
577
|
+
},
|
|
578
|
+
getType: getTypeString,
|
|
579
|
+
getExample: getExampleObjectId,
|
|
419
580
|
};
|
|
420
|
-
|
|
581
|
+
var buildMongoIdStringValidator = function (options) { return ({
|
|
582
|
+
validate: function (o) {
|
|
583
|
+
if (o === void 0) { o = {}; }
|
|
584
|
+
return (0, exports.build_validator)(exports.escapeMongoId, __assign(__assign({}, optionsWithDefaults(__assign(__assign({}, options), o))), { maxLength: 100, listOf: false }));
|
|
585
|
+
},
|
|
586
|
+
getType: getTypeString,
|
|
587
|
+
getExample: getExampleObjectId,
|
|
588
|
+
}); };
|
|
589
|
+
exports.buildMongoIdStringValidator = buildMongoIdStringValidator;
|
|
421
590
|
var nullValidator = function (o) {
|
|
422
591
|
if (o === void 0) { o = {}; }
|
|
423
592
|
return (0, exports.build_validator)(function (v) {
|
|
@@ -427,13 +596,13 @@ var nullValidator = function (o) {
|
|
|
427
596
|
}, __assign(__assign({}, o), { listOf: false }));
|
|
428
597
|
};
|
|
429
598
|
exports.nullValidator = nullValidator;
|
|
430
|
-
exports.mongoIdRequired =
|
|
431
|
-
exports.mongoIdOptional =
|
|
432
|
-
exports.
|
|
433
|
-
exports.
|
|
434
|
-
exports.
|
|
435
|
-
exports.listOfMongoIdStringValidator = (0, exports.listValidator)(
|
|
436
|
-
exports.listOfMongoIdStringValidatorEmptyOk = (0, exports.listValidatorEmptyOk)(
|
|
599
|
+
exports.mongoIdRequired = exports.mongoIdValidator.validate();
|
|
600
|
+
exports.mongoIdOptional = exports.mongoIdValidator.validate({ isOptional: true });
|
|
601
|
+
exports.listOfMongoIdValidator = (0, exports.listValidator)(exports.mongoIdValidator);
|
|
602
|
+
exports.mongoIdStringRequired = (0, exports.buildMongoIdStringValidator)({ isOptional: false });
|
|
603
|
+
exports.mongoIdStringOptional = (0, exports.buildMongoIdStringValidator)({ isOptional: true });
|
|
604
|
+
exports.listOfMongoIdStringValidator = (0, exports.listValidator)(exports.mongoIdStringRequired);
|
|
605
|
+
exports.listOfMongoIdStringValidatorEmptyOk = (0, exports.listValidatorEmptyOk)(exports.mongoIdStringRequired);
|
|
437
606
|
var first_letter_capitalized = function (s) {
|
|
438
607
|
if (s === void 0) { s = ''; }
|
|
439
608
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
@@ -442,201 +611,279 @@ exports.first_letter_capitalized = first_letter_capitalized;
|
|
|
442
611
|
var escape_name = function (namestring) { return namestring.replace(/[^a-zA-Z0-9-_ /.]/, '').substring(0, 100); };
|
|
443
612
|
exports.escape_name = escape_name;
|
|
444
613
|
// enforces first-letter capitalization
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
if (
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
614
|
+
exports.nameValidator = {
|
|
615
|
+
validate: function (options) {
|
|
616
|
+
if (options === void 0) { options = {}; }
|
|
617
|
+
return (0, exports.build_validator)(function (name) {
|
|
618
|
+
if (typeof name !== 'string')
|
|
619
|
+
throw new Error('Expecting string value');
|
|
620
|
+
name = (0, exports.escape_name)(name);
|
|
621
|
+
if (!name)
|
|
622
|
+
throw new Error("Invalid name");
|
|
623
|
+
return (0, exports.first_letter_capitalized)(name);
|
|
624
|
+
}, __assign(__assign({}, options), { maxLength: 100, trim: true, listOf: false }));
|
|
625
|
+
},
|
|
626
|
+
getExample: function () { return 'John'; },
|
|
627
|
+
getType: getTypeString,
|
|
628
|
+
};
|
|
629
|
+
exports.emailValidator = {
|
|
630
|
+
validate: function (options) {
|
|
631
|
+
if (options === void 0) { options = {}; }
|
|
632
|
+
return (0, exports.build_validator)(function (email) {
|
|
633
|
+
if (typeof email !== 'string')
|
|
634
|
+
throw new Error('Expecting string value');
|
|
635
|
+
if (!(0, exports.isEmail)(email)) {
|
|
636
|
+
throw new Error(options.errorMessage || "Invalid email");
|
|
637
|
+
}
|
|
638
|
+
return email.toLowerCase();
|
|
639
|
+
}, __assign(__assign({}, options), { maxLength: 250, listOf: false }));
|
|
640
|
+
},
|
|
641
|
+
getExample: function () { return "example@tellescope.com"; },
|
|
642
|
+
getType: getTypeString,
|
|
643
|
+
};
|
|
644
|
+
exports.emailValidatorOptional = {
|
|
645
|
+
validate: function (options) {
|
|
646
|
+
if (options === void 0) { options = {}; }
|
|
647
|
+
return (0, exports.build_validator)(function (email) {
|
|
648
|
+
if (typeof email !== 'string')
|
|
649
|
+
throw new Error('Expecting string value');
|
|
650
|
+
if (!(0, exports.isEmail)(email)) {
|
|
651
|
+
throw new Error(options.errorMessage || "Invalid email");
|
|
652
|
+
}
|
|
653
|
+
return email.toLowerCase();
|
|
654
|
+
}, __assign(__assign({}, options), { maxLength: 250, listOf: false, isOptional: true, emptyStringOk: true }));
|
|
655
|
+
},
|
|
656
|
+
getExample: function () { return "example@tellescope.com"; },
|
|
657
|
+
getType: getTypeString,
|
|
658
|
+
};
|
|
659
|
+
exports.emailValidatorEmptyOkay = {
|
|
660
|
+
validate: function (options) {
|
|
661
|
+
if (options === void 0) { options = {}; }
|
|
662
|
+
return (0, exports.build_validator)(function (email) {
|
|
663
|
+
if (typeof email !== 'string')
|
|
664
|
+
throw new Error('Expecting string value');
|
|
665
|
+
if (!(0, exports.isEmail)(email)) {
|
|
666
|
+
throw new Error(options.errorMessage || "Invalid email");
|
|
667
|
+
}
|
|
668
|
+
return email.toLowerCase();
|
|
669
|
+
}, __assign(__assign({}, options), { maxLength: 250, emptyStringOk: true, listOf: false }));
|
|
670
|
+
},
|
|
671
|
+
getExample: function () { return "example@tellescope.com"; },
|
|
672
|
+
getType: getTypeString,
|
|
673
|
+
};
|
|
674
|
+
var numberValidatorBuilder = function (_a) {
|
|
675
|
+
var lower = _a.lower, upper = _a.upper, higherOptions = __rest(_a, ["lower", "upper"]);
|
|
676
|
+
return ({
|
|
677
|
+
validate: function (options) {
|
|
678
|
+
if (options === void 0) { options = {}; }
|
|
679
|
+
options.isNumber = true;
|
|
680
|
+
return (0, exports.build_validator)(function (number) {
|
|
681
|
+
number = Number(number); // ok to throw error!
|
|
682
|
+
if (typeof number !== "number" || isNaN(number)) {
|
|
683
|
+
throw new Error(options.errorMessage || "Not a valid number");
|
|
684
|
+
}
|
|
685
|
+
if (!(lower || upper))
|
|
686
|
+
return number;
|
|
687
|
+
if (!(number >= lower && number <= upper)) {
|
|
688
|
+
throw new Error(options.errorMessage || "Not a valid number for [".concat(lower, "-").concat(upper, "]"));
|
|
689
|
+
}
|
|
690
|
+
return number;
|
|
691
|
+
}, __assign(__assign({}, optionsWithDefaults(__assign(__assign({}, higherOptions), options))), { listOf: false }));
|
|
692
|
+
},
|
|
693
|
+
getExample: function () { return "".concat(lower); },
|
|
694
|
+
getType: getTypeNumber,
|
|
695
|
+
});
|
|
479
696
|
};
|
|
480
|
-
exports.emailValidatorEmptyOkay = emailValidatorEmptyOkay;
|
|
481
|
-
var numberValidatorBuilder = function (r) { return function (options) {
|
|
482
|
-
if (options === void 0) { options = {}; }
|
|
483
|
-
options.isNumber = true;
|
|
484
|
-
return (0, exports.build_validator)(function (number) {
|
|
485
|
-
number = Number(number); // ok to throw error!
|
|
486
|
-
if (typeof number !== "number" || isNaN(number)) {
|
|
487
|
-
throw new Error(options.errorMessage || "Not a valid number");
|
|
488
|
-
}
|
|
489
|
-
if (!r)
|
|
490
|
-
return number;
|
|
491
|
-
if (!(number >= r.lower && number <= r.upper)) {
|
|
492
|
-
throw new Error(options.errorMessage || "Not a valid number for [".concat(r.lower, "-").concat(r.upper, "]"));
|
|
493
|
-
}
|
|
494
|
-
return number;
|
|
495
|
-
}, __assign(__assign({}, options), { listOf: false }));
|
|
496
|
-
}; };
|
|
497
697
|
exports.numberValidatorBuilder = numberValidatorBuilder;
|
|
498
698
|
exports.nonNegNumberValidator = (0, exports.numberValidatorBuilder)({ lower: 0, upper: 10000000000000 }); // max is 2286 in UTC MS
|
|
499
699
|
exports.numberValidator = (0, exports.numberValidatorBuilder)({ lower: -100000000, upper: 10000000000000 }); // max is 2286 in UTC MS
|
|
700
|
+
exports.numberValidatorOptional = (0, exports.numberValidatorBuilder)({ lower: -100000000, upper: 10000000000000, isOptional: true, emptyStringOk: true }); // max is 2286 in UTC MS
|
|
500
701
|
exports.fileSizeValidator = (0, exports.numberValidatorBuilder)({ lower: 0, upper: exports.MAX_FILE_SIZE });
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
};
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
return
|
|
517
|
-
|
|
518
|
-
|
|
702
|
+
exports.dateValidator = {
|
|
703
|
+
validate: function (options) {
|
|
704
|
+
if (options === void 0) { options = {}; }
|
|
705
|
+
return (0, exports.build_validator)(function (date) {
|
|
706
|
+
if ((0, exports.isDate)(date))
|
|
707
|
+
throw new Error(options.errorMessage || "Invalid date");
|
|
708
|
+
return new Date(date);
|
|
709
|
+
}, __assign(__assign({}, options), { maxLength: 250, listOf: false }));
|
|
710
|
+
},
|
|
711
|
+
getExample: function () { return new Date().toISOString(); },
|
|
712
|
+
getType: function () { return "Date"; },
|
|
713
|
+
};
|
|
714
|
+
exports.dateValidatorOptional = {
|
|
715
|
+
validate: function (options) {
|
|
716
|
+
if (options === void 0) { options = {}; }
|
|
717
|
+
return (0, exports.build_validator)(function (date) {
|
|
718
|
+
if ((0, exports.isDate)(date))
|
|
719
|
+
throw new Error(options.errorMessage || "Invalid date");
|
|
720
|
+
return new Date(date);
|
|
721
|
+
}, __assign(__assign({}, options), { maxLength: 250, listOf: false, isOptional: true, emptyStringOk: true }));
|
|
722
|
+
},
|
|
723
|
+
getExample: function () { return new Date().toISOString(); },
|
|
724
|
+
getType: function () { return "Date"; },
|
|
725
|
+
};
|
|
726
|
+
var exactMatchValidator = function (matches) { return ({
|
|
727
|
+
validate: function (o) {
|
|
728
|
+
if (o === void 0) { o = {}; }
|
|
729
|
+
return (0, exports.build_validator)(function (match) {
|
|
730
|
+
if (matches.filter(function (m) { return m === match; }).length === 0) {
|
|
731
|
+
throw new Error("Value must match one of ".concat(matches));
|
|
732
|
+
}
|
|
733
|
+
return match;
|
|
734
|
+
}, __assign(__assign({}, o), { listOf: false }));
|
|
735
|
+
},
|
|
736
|
+
getExample: function () { return matches[0]; },
|
|
737
|
+
getType: getTypeString,
|
|
738
|
+
}); };
|
|
519
739
|
exports.exactMatchValidator = exactMatchValidator;
|
|
520
|
-
var
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
740
|
+
var exactMatchValidatorOptional = function (matches) { return ({
|
|
741
|
+
validate: function (o) {
|
|
742
|
+
if (o === void 0) { o = {}; }
|
|
743
|
+
return (0, exports.build_validator)(function (match) {
|
|
744
|
+
if (matches.filter(function (m) { return m === match; }).length === 0) {
|
|
745
|
+
throw new Error("Value must match one of ".concat(matches));
|
|
746
|
+
}
|
|
747
|
+
return match;
|
|
748
|
+
}, __assign(__assign({}, o), { listOf: false, isOptional: true }));
|
|
749
|
+
},
|
|
750
|
+
getExample: function () { return matches[0]; },
|
|
751
|
+
getType: getTypeString,
|
|
752
|
+
}); };
|
|
753
|
+
exports.exactMatchValidatorOptional = exactMatchValidatorOptional;
|
|
754
|
+
var exactMatchListValidator = function (matches) { return (0, exports.listValidator)((0, exports.exactMatchValidator)(matches)); };
|
|
529
755
|
exports.exactMatchListValidator = exactMatchListValidator;
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
756
|
+
exports.journeysValidator = {
|
|
757
|
+
validate: function (options) {
|
|
758
|
+
if (options === void 0) { options = {}; }
|
|
759
|
+
return (0, exports.build_validator)(function (journeys) {
|
|
760
|
+
if (typeof journeys !== 'object') {
|
|
761
|
+
throw new Error('Expecting an object');
|
|
762
|
+
}
|
|
763
|
+
var mIdValidator = exports.mongoIdValidator.validate();
|
|
764
|
+
var stateValidator = exports.stringValidator.validate({ isOptional: true, maxLength: 75, errorMessage: "Journey state names may not exceed 75 characters" });
|
|
765
|
+
for (var j in journeys) {
|
|
766
|
+
mIdValidator(j);
|
|
767
|
+
journeys[j] = stateValidator(journeys[j]);
|
|
768
|
+
}
|
|
769
|
+
return journeys;
|
|
770
|
+
}, __assign(__assign({}, options), { isObject: true, listOf: false }));
|
|
771
|
+
},
|
|
772
|
+
getExample: function () { return "{ ".concat(EXAMPLE_OBJECT_ID, ": \"status\" }"); },
|
|
773
|
+
getType: function () { return "{ string: string }"; },
|
|
544
774
|
};
|
|
545
|
-
exports.journeysValidator = journeysValidator;
|
|
546
775
|
var escape_phone_number = function (p) {
|
|
547
776
|
if (p === void 0) { p = ''; }
|
|
548
777
|
return p.replace(/[^\d+]/g, '');
|
|
549
778
|
};
|
|
550
779
|
exports.escape_phone_number = escape_phone_number;
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
:
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
780
|
+
exports.phoneValidator = {
|
|
781
|
+
validate: function (options) {
|
|
782
|
+
if (options === void 0) { options = {}; }
|
|
783
|
+
return (0, exports.build_validator)(function (phone) {
|
|
784
|
+
if (typeof phone !== "string")
|
|
785
|
+
throw new Error("Expecting phone to be string but got ".concat(phone));
|
|
786
|
+
var escaped = (0, exports.escape_phone_number)(phone);
|
|
787
|
+
if (escaped.length < 10)
|
|
788
|
+
throw new Error("Phone number must be at least 10 digits");
|
|
789
|
+
escaped = escaped.startsWith('+') ? escaped
|
|
790
|
+
: escaped.length === 10 ? '+1' + escaped // assume US country code for now
|
|
791
|
+
: "+" + escaped; // assume country code provided, but missing leading +
|
|
792
|
+
if (!(0, exports.isMobilePhone)(escaped, 'any', { strictMode: true })) {
|
|
793
|
+
throw "Invalid phone number";
|
|
794
|
+
}
|
|
795
|
+
return escaped;
|
|
796
|
+
}, __assign(__assign({}, options), { maxLength: 25, listOf: false }));
|
|
797
|
+
},
|
|
798
|
+
getExample: function () { return "+15555555555"; },
|
|
799
|
+
getType: getTypeString,
|
|
800
|
+
};
|
|
801
|
+
exports.phoneValidatorOptional = {
|
|
802
|
+
validate: function (options) {
|
|
803
|
+
if (options === void 0) { options = {}; }
|
|
804
|
+
return (0, exports.build_validator)(function (phone) {
|
|
805
|
+
if (typeof phone !== "string")
|
|
806
|
+
throw new Error("Expecting phone to be string but got ".concat(phone));
|
|
807
|
+
var escaped = (0, exports.escape_phone_number)(phone);
|
|
808
|
+
if (escaped.length < 10)
|
|
809
|
+
throw new Error("Phone number must be at least 10 digits");
|
|
810
|
+
escaped = escaped.startsWith('+') ? escaped
|
|
811
|
+
: escaped.length === 10 ? '+1' + escaped // assume US country code for now
|
|
812
|
+
: "+" + escaped; // assume country code provided, but missing leading +
|
|
813
|
+
if (!(0, exports.isMobilePhone)(escaped, 'any', { strictMode: true })) {
|
|
814
|
+
throw "Invalid phone number";
|
|
815
|
+
}
|
|
816
|
+
return escaped;
|
|
817
|
+
}, __assign(__assign({}, options), { maxLength: 25, listOf: false, isOptional: true, emptyStringOk: true }));
|
|
818
|
+
},
|
|
819
|
+
getExample: function () { return "+15555555555"; },
|
|
820
|
+
getType: getTypeString,
|
|
821
|
+
};
|
|
822
|
+
exports.fileTypeValidator = {
|
|
823
|
+
validate: function (options) {
|
|
824
|
+
if (options === void 0) { options = {}; }
|
|
825
|
+
return (0, exports.build_validator)(function (s) {
|
|
826
|
+
if (typeof s !== 'string')
|
|
827
|
+
throw new Error("fileType must be a string");
|
|
828
|
+
if (!(0, exports.isMimeType)(s))
|
|
829
|
+
throw new Error("".concat(s, " is not a valid file type"));
|
|
830
|
+
return s;
|
|
831
|
+
}, __assign(__assign({}, options), { listOf: false }));
|
|
832
|
+
},
|
|
833
|
+
getExample: function () { return 'text/plain'; },
|
|
834
|
+
getType: getTypeString,
|
|
835
|
+
};
|
|
836
|
+
exports.urlValidator = {
|
|
837
|
+
validate: function (options) {
|
|
838
|
+
if (options === void 0) { options = {}; }
|
|
839
|
+
return (0, exports.build_validator)(function (s) {
|
|
840
|
+
if (typeof s !== 'string')
|
|
841
|
+
throw new Error("URL must be a string");
|
|
842
|
+
if (!(0, exports.isURL)(s))
|
|
843
|
+
throw new Error("".concat(s, " is not a valid URL"));
|
|
844
|
+
return s;
|
|
845
|
+
}, __assign(__assign({}, options), { listOf: false }));
|
|
846
|
+
},
|
|
847
|
+
getExample: function () { return '"https://www.tellescope.com"'; },
|
|
848
|
+
getType: getTypeString,
|
|
849
|
+
};
|
|
850
|
+
exports.safeBase64Validator = {
|
|
851
|
+
validate: function (options) {
|
|
852
|
+
if (options === void 0) { options = {}; }
|
|
853
|
+
return (0, exports.build_validator)(function (sb64) {
|
|
854
|
+
if (typeof sb64 !== 'string')
|
|
855
|
+
throw new Error("Expecting string");
|
|
856
|
+
// https://stackoverflow.com/questions/12930007/how-to-validate-base64-string-using-regex-in-javascript
|
|
857
|
+
// regex with = + and / replaced as get_random_base64_URL_safe
|
|
858
|
+
if (!/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}..|[A-Za-z0-9_-]{3}.)?$/.test(sb64)) {
|
|
859
|
+
throw "Invalid safe base64";
|
|
860
|
+
}
|
|
861
|
+
return sb64;
|
|
862
|
+
}, __assign(__assign({}, options), { listOf: false }));
|
|
863
|
+
},
|
|
864
|
+
getExample: function () { return '129vjas0fkj1234jgfmnaef'; },
|
|
865
|
+
getType: getTypeString,
|
|
866
|
+
};
|
|
867
|
+
exports.subdomainValidator = {
|
|
868
|
+
validate: function (options) {
|
|
869
|
+
if (options === void 0) { options = {}; }
|
|
870
|
+
return (0, exports.build_validator)(function (subdomain) {
|
|
871
|
+
if (typeof subdomain !== 'string')
|
|
872
|
+
throw new Error("Expecting string value");
|
|
873
|
+
subdomain = subdomain.toLowerCase();
|
|
874
|
+
if (subdomain.startsWith('-')) {
|
|
875
|
+
subdomain = subdomain.substring(1);
|
|
876
|
+
}
|
|
877
|
+
while (subdomain.endsWith('-')) {
|
|
878
|
+
subdomain = subdomain.substring(0, subdomain.length - 1);
|
|
879
|
+
}
|
|
880
|
+
subdomain = subdomain.replace(/[^a-zA-Z\d-]/g, '');
|
|
881
|
+
return subdomain;
|
|
882
|
+
}, __assign(__assign({}, options), { maxLength: 50, listOf: false }));
|
|
883
|
+
},
|
|
884
|
+
getExample: function () { return 'example'; },
|
|
885
|
+
getType: getTypeString,
|
|
638
886
|
};
|
|
639
|
-
exports.subdomainValidator = subdomainValidator;
|
|
640
887
|
// export const fileResponseValidator: EscapeBuilder<FileResponse> = (options={}) => build_validator(
|
|
641
888
|
// (file: any) => {
|
|
642
889
|
// if (!file.secureName) throw new Error("Missing name")
|
|
@@ -649,14 +896,14 @@ exports.subdomainValidator = subdomainValidator;
|
|
|
649
896
|
// { ...options, isObject: true, listOf: false }
|
|
650
897
|
// )
|
|
651
898
|
exports.fileResponseValidator = (0, exports.objectValidator)({
|
|
652
|
-
type: (0, exports.exactMatchValidator)(['file'])
|
|
653
|
-
name:
|
|
654
|
-
secureName:
|
|
899
|
+
type: (0, exports.exactMatchValidator)(['file']),
|
|
900
|
+
name: exports.stringValidator1000,
|
|
901
|
+
secureName: exports.stringValidator250,
|
|
655
902
|
});
|
|
656
903
|
exports.signatureResponseValidator = (0, exports.objectValidator)({
|
|
657
|
-
type: (0, exports.exactMatchValidator)(['signature'])
|
|
658
|
-
fullName:
|
|
659
|
-
signed:
|
|
904
|
+
type: (0, exports.exactMatchValidator)(['signature']),
|
|
905
|
+
fullName: exports.stringValidator100,
|
|
906
|
+
signed: exports.booleanValidator,
|
|
660
907
|
});
|
|
661
908
|
var DEFAULT_ENDUSER_FIELDS = [
|
|
662
909
|
'_id', 'email', 'phone', 'fname', 'lname', 'journeys', 'tags', 'preference'
|
|
@@ -686,26 +933,28 @@ var _FORM_FIELD_TYPES = {
|
|
|
686
933
|
exports.FORM_FIELD_TYPES = Object.keys(_FORM_FIELD_TYPES);
|
|
687
934
|
exports.formFieldTypeValidator = (0, exports.exactMatchValidator)(exports.FORM_FIELD_TYPES);
|
|
688
935
|
exports.FORM_FIELD_VALIDATORS_BY_TYPE = {
|
|
689
|
-
'string':
|
|
690
|
-
'number':
|
|
691
|
-
'email':
|
|
692
|
-
|
|
693
|
-
'
|
|
694
|
-
'
|
|
695
|
-
|
|
936
|
+
'string': exports.stringValidator.validate({ maxLength: 5000, emptyStringOk: true, errorMessage: "Response must not exceed 5000 characters" }),
|
|
937
|
+
'number': exports.numberValidator.validate({ errorMessage: "Response must be a number" }),
|
|
938
|
+
'email': exports.emailValidator.validate(),
|
|
939
|
+
'userEmail': exports.emailValidator.validate(),
|
|
940
|
+
'phone': exports.phoneValidator.validate(),
|
|
941
|
+
'phoneNumber': exports.phoneValidator.validate(),
|
|
942
|
+
"date": exports.dateValidator.validate(),
|
|
943
|
+
"ranking": exports.listOfStringsValidator.validate(),
|
|
944
|
+
"rating": exports.numberValidator.validate(),
|
|
696
945
|
// fileInfo: FileResponse
|
|
697
946
|
'file': function (fileInfo, _, isOptional) {
|
|
698
947
|
if (isOptional && (!fileInfo || (0, utilities_1.object_is_empty)(fileInfo))) {
|
|
699
948
|
return { type: 'file', secureName: null };
|
|
700
949
|
}
|
|
701
|
-
return
|
|
950
|
+
return exports.fileResponseValidator.validate()(fileInfo);
|
|
702
951
|
},
|
|
703
952
|
// sigInfo: SignatureResponse
|
|
704
953
|
'signature': function (sigInfo, _, isOptional) {
|
|
705
954
|
if (isOptional && (!sigInfo || (0, utilities_1.object_is_empty)(sigInfo))) {
|
|
706
955
|
return { type: 'signature', signed: null };
|
|
707
956
|
}
|
|
708
|
-
return
|
|
957
|
+
return exports.signatureResponseValidator.validate()(sigInfo);
|
|
709
958
|
},
|
|
710
959
|
// choiceInfo: { indexes: [], otherText?: string }
|
|
711
960
|
'multiple_choice': function (choiceInfo, fieldOptions, isOptional) {
|
|
@@ -734,82 +983,86 @@ exports.FORM_FIELD_VALIDATORS_BY_TYPE = {
|
|
|
734
983
|
return parsed;
|
|
735
984
|
},
|
|
736
985
|
};
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
if (val
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
if (
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
986
|
+
exports.fieldsValidator = {
|
|
987
|
+
validate: function (options) {
|
|
988
|
+
if (options === void 0) { options = {}; }
|
|
989
|
+
return (0, exports.build_validator)(function (fields) {
|
|
990
|
+
if (!(0, utilities_1.is_object)(fields))
|
|
991
|
+
throw new Error("Expecting an object");
|
|
992
|
+
for (var k in fields) {
|
|
993
|
+
if (DEFAULT_ENDUSER_FIELDS.includes(k))
|
|
994
|
+
throw new Error("key ".concat(k, " conflicts with a built-in field."));
|
|
995
|
+
if (k.startsWith('_'))
|
|
996
|
+
throw new Error("Fields that start with '_' are not allowed");
|
|
997
|
+
if ((0, utilities_1.is_whitespace)(k)) {
|
|
998
|
+
delete fields[k];
|
|
999
|
+
continue;
|
|
1000
|
+
}
|
|
1001
|
+
if (k.length > 32)
|
|
1002
|
+
throw new Error("key ".concat(k, " is greater than 32 characters"));
|
|
1003
|
+
var val = fields[k];
|
|
1004
|
+
if (typeof val === 'string') {
|
|
1005
|
+
if (val.length > 512)
|
|
1006
|
+
fields[k] = val.substring(0, 512);
|
|
1007
|
+
continue;
|
|
1008
|
+
}
|
|
1009
|
+
else if (typeof val === 'number' || val === null || typeof val === 'boolean') {
|
|
1010
|
+
continue; // nothing to restrict on number type yet
|
|
1011
|
+
}
|
|
1012
|
+
else if (typeof val === 'object') {
|
|
1013
|
+
if (JSON.stringify(val).length > 1024)
|
|
1014
|
+
throw new Error("object value for key ".concat(k, " exceeds the maximum length of 1024 characters in string representation"));
|
|
1015
|
+
// previous restricted structure for fields object
|
|
1016
|
+
// try {
|
|
1017
|
+
// if (val.type && typeof val.type === 'string') { // form responses can be stored as custom fields (form responses is simple array)
|
|
1018
|
+
// FORM_FIELD_VALIDATORS_BY_TYPE[val.type as keyof typeof FORM_FIELD_VALIDATORS_BY_TYPE](val, undefined as never, undefined as never)
|
|
1019
|
+
// continue
|
|
1020
|
+
// }
|
|
1021
|
+
// if (val.length && typeof val.length === 'number') { // array of strings is ok too, (inclusive of multiple-choice responses)
|
|
1022
|
+
// if (val.find((s: any) => typeof s !== 'string') !== undefined) {
|
|
1023
|
+
// throw new Error('List must contain only strings')
|
|
1024
|
+
// }
|
|
1025
|
+
// continue
|
|
1026
|
+
// }
|
|
1027
|
+
// if (val.value === undefined) throw new Error(`value field is undefined for key ${k}`)
|
|
1028
|
+
// if (JSON.stringify(val).length > 1024) throw new Error(`object value for key ${k} exceeds the maximum length of 1024 characters in string representation`)
|
|
1029
|
+
// const escaped = { value: val.value } as Indexable // create new object to omit unrecognized fields
|
|
1030
|
+
// escaped.title = val.title // optional
|
|
1031
|
+
// escaped.description = val.description // optional
|
|
1032
|
+
// fields[k] = escaped
|
|
1033
|
+
// } catch(err) {
|
|
1034
|
+
// throw new Error(`object value is invalid JSON for key ${k}`)
|
|
1035
|
+
// }
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
throw new Error("Expecting value to be a string or object but got ".concat(typeof val, " for key {k}"));
|
|
1039
|
+
}
|
|
789
1040
|
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
},
|
|
1041
|
+
return fields;
|
|
1042
|
+
}, __assign(__assign({}, options), { isObject: true, listOf: false }));
|
|
1043
|
+
},
|
|
1044
|
+
getExample: function () { return "{}"; },
|
|
1045
|
+
getType: function () { return "{}"; },
|
|
793
1046
|
};
|
|
794
|
-
exports.fieldsValidator = fieldsValidator;
|
|
795
1047
|
exports.preferenceValidator = (0, exports.exactMatchValidator)(['email', 'sms', 'call', 'chat']);
|
|
796
1048
|
exports.updateOptionsValidator = (0, exports.objectValidator)({
|
|
797
|
-
replaceObjectFields:
|
|
798
|
-
});
|
|
1049
|
+
replaceObjectFields: exports.booleanValidatorOptional,
|
|
1050
|
+
}, { isOptional: true });
|
|
799
1051
|
exports.journeyStatePriorityValidator = (0, exports.exactMatchValidator)(["Disengaged", "N/A", "Engaged"]);
|
|
800
1052
|
exports.journeyStateValidator = (0, exports.objectValidator)({
|
|
801
|
-
name:
|
|
802
|
-
priority:
|
|
803
|
-
description:
|
|
804
|
-
requiresFollowup:
|
|
1053
|
+
name: exports.stringValidator100,
|
|
1054
|
+
priority: exports.journeyStatePriorityValidator,
|
|
1055
|
+
description: exports.stringValidatorOptional,
|
|
1056
|
+
requiresFollowup: exports.booleanValidatorOptional, // deprecated
|
|
805
1057
|
});
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
})
|
|
812
|
-
|
|
1058
|
+
// deprecated
|
|
1059
|
+
// export const journeyStateUpdateValidator = objectValidator<JourneyState>({
|
|
1060
|
+
// name: stringValidator100({ isOptional: true }),
|
|
1061
|
+
// priority: journeyStatePriorityValidator({ isOptional: true }),
|
|
1062
|
+
// description: stringValidator({ isOptional: true }),
|
|
1063
|
+
// requiresFollowup: booleanValidator({ isOptional: true }),
|
|
1064
|
+
// })
|
|
1065
|
+
exports.journeyStatesValidator = (0, exports.listValidator)(exports.journeyStateValidator);
|
|
813
1066
|
exports.emailEncodingValidator = (0, exports.exactMatchValidator)(['', 'base64']);
|
|
814
1067
|
var validateIndexable = function (keyValidator, valueValidator) { return function (o) { return (0, exports.build_validator)(function (v) {
|
|
815
1068
|
if (!(0, utilities_1.is_object)(v))
|
|
@@ -821,21 +1074,29 @@ var validateIndexable = function (keyValidator, valueValidator) { return functio
|
|
|
821
1074
|
return validated;
|
|
822
1075
|
}, __assign(__assign({}, o), { isObject: true, listOf: false })); }; };
|
|
823
1076
|
exports.validateIndexable = validateIndexable;
|
|
824
|
-
var indexableValidator = function (keyValidator, valueValidator) { return (
|
|
1077
|
+
var indexableValidator = function (keyValidator, valueValidator) { return ({
|
|
1078
|
+
validate: (0, exports.validateIndexable)(keyValidator.validate(), valueValidator.validate()),
|
|
1079
|
+
getExample: function () { return "{ ".concat(keyValidator.getExample(), ": ").concat(valueValidator.getExample(), " }"); },
|
|
1080
|
+
getType: function () { return "{ ".concat(keyValidator.getType(), ": ").concat(valueValidator.getType(), " }"); },
|
|
1081
|
+
}); };
|
|
825
1082
|
exports.indexableValidator = indexableValidator;
|
|
826
|
-
var indexableNumberValidator = function (keyValidator, valueValidator) { return (
|
|
1083
|
+
var indexableNumberValidator = function (keyValidator, valueValidator) { return ({
|
|
1084
|
+
validate: (0, exports.validateIndexable)(keyValidator.validate(), valueValidator.validate()),
|
|
1085
|
+
getExample: function () { return "{ ".concat(keyValidator.getExample(), ": ").concat(valueValidator.getExample(), " }"); },
|
|
1086
|
+
getType: function () { return "{ ".concat(keyValidator.getType(), ": ").concat(valueValidator.getType(), " }"); },
|
|
1087
|
+
}); };
|
|
827
1088
|
exports.indexableNumberValidator = indexableNumberValidator;
|
|
828
1089
|
var rejectionWithMessage = function (o) { return (0, exports.build_validator)(function (v) { throw new Error((o === null || o === void 0 ? void 0 : o.errorMessage) || 'This field is not valid'); }, __assign(__assign({}, o), { isOptional: true, listOf: false })); };
|
|
829
1090
|
exports.rejectionWithMessage = rejectionWithMessage;
|
|
830
|
-
exports.numberToDateValidator = (0, exports.indexableNumberValidator)(
|
|
831
|
-
exports.idStringToDateValidator = (0, exports.indexableValidator)(
|
|
1091
|
+
exports.numberToDateValidator = (0, exports.indexableNumberValidator)(exports.numberValidator, exports.dateValidator);
|
|
1092
|
+
exports.idStringToDateValidator = (0, exports.indexableValidator)(exports.mongoIdStringRequired, exports.dateValidator);
|
|
832
1093
|
// todo: move preference to FIELD_TYPES with drop-down option in user-facing forms
|
|
833
1094
|
var FIELD_TYPES = ['string', 'number', 'email', 'phone', 'multiple_choice', 'file', 'signature'];
|
|
834
1095
|
var VALIDATE_OPTIONS_FOR_FIELD_TYPES = {
|
|
835
1096
|
'multiple_choice': {
|
|
836
|
-
choices:
|
|
837
|
-
radio:
|
|
838
|
-
other:
|
|
1097
|
+
choices: exports.listOfStringsValidator,
|
|
1098
|
+
radio: exports.booleanValidator,
|
|
1099
|
+
other: exports.booleanValidatorOptional,
|
|
839
1100
|
REQUIRED: ['choices', 'radio'],
|
|
840
1101
|
}
|
|
841
1102
|
};
|
|
@@ -878,17 +1139,17 @@ var isFormField = function (f, fieldOptions) {
|
|
|
878
1139
|
if (!forUpdate && !field.type)
|
|
879
1140
|
throw "field.type is required"; // fieldName otherwise given as 'field' in validation for every subfield
|
|
880
1141
|
if (field.type)
|
|
881
|
-
(0, exports.exactMatchValidator)(FIELD_TYPES)(field.type);
|
|
1142
|
+
(0, exports.exactMatchValidator)(FIELD_TYPES).validate(field.type);
|
|
882
1143
|
if (!forUpdate && !field.title)
|
|
883
1144
|
throw "field.title is required"; // fieldName otherwise given as 'field' in validation for every subfield
|
|
884
1145
|
if (field.title) {
|
|
885
|
-
field.title =
|
|
1146
|
+
field.title = exports.stringValidator.validate({
|
|
886
1147
|
maxLength: 100,
|
|
887
1148
|
errorMessage: "field title is required and must not exceed 100 characters"
|
|
888
1149
|
})(field.title);
|
|
889
1150
|
}
|
|
890
1151
|
if (!forUpdate || field.description !== undefined) { // don't overwrite description on update with ''
|
|
891
|
-
field.description =
|
|
1152
|
+
field.description = exports.stringValidator.validate({
|
|
892
1153
|
isOptional: true,
|
|
893
1154
|
maxLength: 500,
|
|
894
1155
|
errorMessage: "field description must be under 500 characters"
|
|
@@ -912,7 +1173,7 @@ var isFormField = function (f, fieldOptions) {
|
|
|
912
1173
|
if (validators[k] === undefined) {
|
|
913
1174
|
throw new Error("Got unexpected option ".concat(k, " for field of type ").concat(exports.INTERNAL_NAME_TO_DISPLAY_FIELD[field.type] || 'Text'));
|
|
914
1175
|
}
|
|
915
|
-
field.options[k] = validators[k](field.options[k]);
|
|
1176
|
+
field.options[k] = validators[k].validate(field.options[k]);
|
|
916
1177
|
}
|
|
917
1178
|
}
|
|
918
1179
|
if (field.intakeField !== undefined) { // allow null to unset intake
|
|
@@ -929,58 +1190,59 @@ var isFormField = function (f, fieldOptions) {
|
|
|
929
1190
|
// validate optional vs not at endpoint-level
|
|
930
1191
|
exports.formResponseAnswerValidator = (0, exports.orValidator)({
|
|
931
1192
|
email: (0, exports.objectValidator)({
|
|
932
|
-
type: (0, exports.exactMatchValidator)(['email'])
|
|
933
|
-
value:
|
|
934
|
-
})
|
|
1193
|
+
type: (0, exports.exactMatchValidator)(['email']),
|
|
1194
|
+
value: exports.emailValidatorOptional,
|
|
1195
|
+
}),
|
|
935
1196
|
number: (0, exports.objectValidator)({
|
|
936
|
-
type: (0, exports.exactMatchValidator)(['number'])
|
|
937
|
-
value:
|
|
938
|
-
})
|
|
1197
|
+
type: (0, exports.exactMatchValidator)(['number']),
|
|
1198
|
+
value: exports.numberValidatorOptional,
|
|
1199
|
+
}),
|
|
939
1200
|
rating: (0, exports.objectValidator)({
|
|
940
|
-
type: (0, exports.exactMatchValidator)(['rating'])
|
|
941
|
-
value:
|
|
942
|
-
})
|
|
1201
|
+
type: (0, exports.exactMatchValidator)(['rating']),
|
|
1202
|
+
value: exports.numberValidatorOptional,
|
|
1203
|
+
}),
|
|
943
1204
|
phone: (0, exports.objectValidator)({
|
|
944
|
-
type: (0, exports.exactMatchValidator)(['phone'])
|
|
945
|
-
value:
|
|
946
|
-
})
|
|
1205
|
+
type: (0, exports.exactMatchValidator)(['phone']),
|
|
1206
|
+
value: exports.phoneValidatorOptional,
|
|
1207
|
+
}),
|
|
947
1208
|
string: (0, exports.objectValidator)({
|
|
948
|
-
type: (0, exports.exactMatchValidator)(['string'])
|
|
949
|
-
value:
|
|
950
|
-
})
|
|
1209
|
+
type: (0, exports.exactMatchValidator)(['string']),
|
|
1210
|
+
value: exports.stringValidator5000Optional,
|
|
1211
|
+
}),
|
|
951
1212
|
date: (0, exports.objectValidator)({
|
|
952
|
-
type: (0, exports.exactMatchValidator)(['date'])
|
|
953
|
-
value:
|
|
954
|
-
})
|
|
1213
|
+
type: (0, exports.exactMatchValidator)(['date']),
|
|
1214
|
+
value: exports.dateValidatorOptional,
|
|
1215
|
+
}),
|
|
955
1216
|
file: (0, exports.objectValidator)({
|
|
956
|
-
type: (0, exports.exactMatchValidator)(['file'])
|
|
1217
|
+
type: (0, exports.exactMatchValidator)(['file']),
|
|
957
1218
|
value: (0, exports.objectValidator)({
|
|
958
|
-
name:
|
|
959
|
-
secureName:
|
|
960
|
-
}, { emptyOk: false
|
|
961
|
-
})
|
|
1219
|
+
name: exports.stringValidator5000,
|
|
1220
|
+
secureName: exports.stringValidator250,
|
|
1221
|
+
}, { emptyOk: false, isOptional: true }),
|
|
1222
|
+
}),
|
|
962
1223
|
multiple_choice: (0, exports.objectValidator)({
|
|
963
|
-
type: (0, exports.exactMatchValidator)(['multiple_choice'])
|
|
964
|
-
value:
|
|
965
|
-
})
|
|
1224
|
+
type: (0, exports.exactMatchValidator)(['multiple_choice']),
|
|
1225
|
+
value: exports.listOfStringsValidatorEmptyOk,
|
|
1226
|
+
}),
|
|
966
1227
|
ranking: (0, exports.objectValidator)({
|
|
967
|
-
type: (0, exports.exactMatchValidator)(['ranking'])
|
|
968
|
-
value:
|
|
969
|
-
})
|
|
1228
|
+
type: (0, exports.exactMatchValidator)(['ranking']),
|
|
1229
|
+
value: exports.listOfStringsValidatorOptionalOrEmptyOk,
|
|
1230
|
+
}),
|
|
970
1231
|
signature: (0, exports.objectValidator)({
|
|
971
|
-
type: (0, exports.exactMatchValidator)(['signature'])
|
|
1232
|
+
type: (0, exports.exactMatchValidator)(['signature']),
|
|
972
1233
|
value: (0, exports.objectValidator)({
|
|
973
|
-
fullName:
|
|
974
|
-
signed:
|
|
975
|
-
}, { emptyOk: false
|
|
976
|
-
})
|
|
1234
|
+
fullName: exports.stringValidator250,
|
|
1235
|
+
signed: exports.booleanValidator,
|
|
1236
|
+
}, { emptyOk: false, isOptional: true }),
|
|
1237
|
+
}),
|
|
977
1238
|
});
|
|
978
1239
|
exports.formResponseValidator = (0, exports.objectValidator)({
|
|
979
1240
|
fieldId: exports.mongoIdStringRequired,
|
|
980
|
-
fieldTitle:
|
|
981
|
-
|
|
1241
|
+
fieldTitle: exports.stringValidator5000,
|
|
1242
|
+
fieldDescription: exports.stringValidator5000Optional,
|
|
1243
|
+
answer: exports.formResponseAnswerValidator,
|
|
982
1244
|
});
|
|
983
|
-
exports.formResponsesValidator = (0, exports.listValidator)(
|
|
1245
|
+
exports.formResponsesValidator = (0, exports.listValidator)(exports.formResponseValidator);
|
|
984
1246
|
exports.intakePhoneValidator = (0, exports.exactMatchValidator)(['optional', 'required']);
|
|
985
1247
|
var formFieldValidator = function (options, fieldOptions) {
|
|
986
1248
|
if (options === void 0) { options = {}; }
|
|
@@ -1034,10 +1296,10 @@ var _CUD = {
|
|
|
1034
1296
|
exports.CUD = Object.keys(_CUD);
|
|
1035
1297
|
exports.CUDStringValidator = (0, exports.exactMatchValidator)(exports.CUD);
|
|
1036
1298
|
exports.CUDValidator = (0, exports.objectValidator)({
|
|
1037
|
-
create:
|
|
1038
|
-
update:
|
|
1039
|
-
delete:
|
|
1040
|
-
});
|
|
1299
|
+
create: exports.booleanValidatorOptional,
|
|
1300
|
+
update: exports.booleanValidatorOptional,
|
|
1301
|
+
delete: exports.booleanValidatorOptional,
|
|
1302
|
+
}, { isOptional: true });
|
|
1041
1303
|
var _UNIT_OF_TIME = {
|
|
1042
1304
|
Days: '',
|
|
1043
1305
|
Hours: '',
|
|
@@ -1048,58 +1310,58 @@ exports.UNITS_OF_TIME = Object.keys(_UNIT_OF_TIME);
|
|
|
1048
1310
|
exports.UnitOfTimeValidator = (0, exports.exactMatchValidator)(exports.UNITS_OF_TIME);
|
|
1049
1311
|
var WebhookSubscriptionValidatorObject = {};
|
|
1050
1312
|
for (var model in types_models_1.WEBHOOK_MODELS) {
|
|
1051
|
-
WebhookSubscriptionValidatorObject[model] =
|
|
1313
|
+
WebhookSubscriptionValidatorObject[model] = exports.CUDValidator;
|
|
1052
1314
|
}
|
|
1053
1315
|
exports.WebhookSubscriptionValidator = (0, exports.objectValidator)(WebhookSubscriptionValidatorObject, { throwOnUnrecognizedField: true });
|
|
1054
1316
|
exports.sessionTypeValidator = (0, exports.exactMatchValidator)(['user', 'enduser']);
|
|
1055
1317
|
exports.listOfDisplayNameInfo = (0, exports.listValidator)((0, exports.objectValidator)({
|
|
1056
|
-
fname:
|
|
1057
|
-
lname:
|
|
1058
|
-
id:
|
|
1059
|
-
})
|
|
1318
|
+
fname: exports.nameValidator,
|
|
1319
|
+
lname: exports.nameValidator,
|
|
1320
|
+
id: exports.listOfMongoIdStringValidator,
|
|
1321
|
+
}));
|
|
1060
1322
|
exports.attendeeInfoValidator = (0, exports.objectValidator)({
|
|
1061
|
-
AttendeeId:
|
|
1062
|
-
ExternalUserId:
|
|
1063
|
-
JoinToken:
|
|
1323
|
+
AttendeeId: exports.stringValidator,
|
|
1324
|
+
ExternalUserId: exports.mongoIdStringRequired,
|
|
1325
|
+
JoinToken: exports.stringValidator,
|
|
1064
1326
|
});
|
|
1065
1327
|
exports.attendeeValidator = (0, exports.objectValidator)({
|
|
1066
|
-
type:
|
|
1067
|
-
id:
|
|
1068
|
-
info:
|
|
1328
|
+
type: exports.sessionTypeValidator,
|
|
1329
|
+
id: exports.mongoIdStringRequired,
|
|
1330
|
+
info: exports.attendeeInfoValidator,
|
|
1069
1331
|
});
|
|
1070
|
-
exports.listOfAttendeesValidator = (0, exports.listValidator)(
|
|
1332
|
+
exports.listOfAttendeesValidator = (0, exports.listValidator)(exports.attendeeValidator);
|
|
1071
1333
|
exports.meetingInfoValidator = (0, exports.objectValidator)({
|
|
1072
|
-
Meeting:
|
|
1334
|
+
Meeting: exports.objectAnyFieldsAnyValuesValidator,
|
|
1073
1335
|
});
|
|
1074
1336
|
exports.userIdentityValidator = (0, exports.objectValidator)({
|
|
1075
|
-
type:
|
|
1076
|
-
id:
|
|
1337
|
+
type: exports.sessionTypeValidator,
|
|
1338
|
+
id: exports.mongoIdStringRequired,
|
|
1077
1339
|
});
|
|
1078
|
-
exports.listOfUserIndentitiesValidator = (0, exports.listValidator)(
|
|
1340
|
+
exports.listOfUserIndentitiesValidator = (0, exports.listValidator)(exports.userIdentityValidator);
|
|
1079
1341
|
exports.chatAttachmentValidator = (0, exports.objectValidator)({
|
|
1080
|
-
type: (0, exports.exactMatchValidator)(['image', 'video', 'file'])
|
|
1081
|
-
secureName:
|
|
1342
|
+
type: (0, exports.exactMatchValidator)(['image', 'video', 'file']),
|
|
1343
|
+
secureName: exports.stringValidator250,
|
|
1082
1344
|
});
|
|
1083
|
-
exports.listOfChatAttachmentsValidator = (0, exports.listValidatorEmptyOk)(
|
|
1345
|
+
exports.listOfChatAttachmentsValidator = (0, exports.listValidatorEmptyOk)(exports.chatAttachmentValidator);
|
|
1084
1346
|
exports.meetingsListValidator = (0, exports.listValidator)((0, exports.objectValidator)({
|
|
1085
|
-
id:
|
|
1086
|
-
updatedAt:
|
|
1087
|
-
status:
|
|
1088
|
-
})
|
|
1347
|
+
id: exports.mongoIdStringRequired,
|
|
1348
|
+
updatedAt: exports.stringValidator,
|
|
1349
|
+
status: exports.meetingStatusValidator,
|
|
1350
|
+
}));
|
|
1089
1351
|
exports.userDisplayInfoValidator = (0, exports.objectValidator)({
|
|
1090
|
-
id: exports.
|
|
1091
|
-
createdAt:
|
|
1092
|
-
avatar:
|
|
1093
|
-
fname:
|
|
1094
|
-
lname:
|
|
1095
|
-
lastActive:
|
|
1096
|
-
lastLogout:
|
|
1097
|
-
email:
|
|
1352
|
+
id: exports.mongoIdStringRequired,
|
|
1353
|
+
createdAt: exports.dateValidator,
|
|
1354
|
+
avatar: exports.stringValidator,
|
|
1355
|
+
fname: exports.nameValidator,
|
|
1356
|
+
lname: exports.nameValidator,
|
|
1357
|
+
lastActive: exports.dateValidator,
|
|
1358
|
+
lastLogout: exports.dateValidator,
|
|
1359
|
+
email: exports.emailValidator,
|
|
1098
1360
|
});
|
|
1099
|
-
exports.meetingDisplayInfoValidator = (0, exports.indexableValidator)(exports.mongoIdStringRequired,
|
|
1361
|
+
exports.meetingDisplayInfoValidator = (0, exports.indexableValidator)(exports.mongoIdStringRequired, exports.userDisplayInfoValidator);
|
|
1100
1362
|
exports.chatRoomUserInfoValidator = (0, exports.objectAnyFieldsValidator)((0, exports.objectValidator)({
|
|
1101
|
-
unreadCount:
|
|
1102
|
-
})
|
|
1363
|
+
unreadCount: exports.nonNegNumberValidator,
|
|
1364
|
+
}));
|
|
1103
1365
|
var _AUTOMATION_ENDUSER_STATUS = {
|
|
1104
1366
|
active: '',
|
|
1105
1367
|
finished: '',
|
|
@@ -1134,129 +1396,136 @@ var _MESSAGE_TEMPLATE_MODES = {
|
|
|
1134
1396
|
exports.MESSAGE_TEMPLATE_MODES = Object.keys(_MESSAGE_TEMPLATE_MODES);
|
|
1135
1397
|
exports.messageTemplateModeValidator = (0, exports.exactMatchValidator)(exports.MESSAGE_TEMPLATE_MODES);
|
|
1136
1398
|
var sharedReminderValidators = {
|
|
1137
|
-
msBeforeStartTime:
|
|
1138
|
-
didRemind:
|
|
1399
|
+
msBeforeStartTime: exports.nonNegNumberValidator,
|
|
1400
|
+
didRemind: exports.booleanValidatorOptional,
|
|
1139
1401
|
};
|
|
1140
1402
|
exports.calendarEventReminderValidator = (0, exports.orValidator)({
|
|
1141
|
-
webhook: (0, exports.objectValidator)(__assign({ info: (0, exports.objectValidator)({}, { emptyOk: true
|
|
1403
|
+
webhook: (0, exports.objectValidator)(__assign({ info: (0, exports.objectValidator)({}, { emptyOk: true, isOptional: true }), type: (0, exports.exactMatchValidator)(['webhook']) }, sharedReminderValidators)),
|
|
1142
1404
|
'add-to-journey': (0, exports.objectValidator)(__assign({ info: (0, exports.objectValidator)({
|
|
1143
|
-
journeyId: exports.
|
|
1144
|
-
})
|
|
1405
|
+
journeyId: exports.mongoIdStringRequired,
|
|
1406
|
+
}), type: (0, exports.exactMatchValidator)(['add-to-journey']) }, sharedReminderValidators)),
|
|
1145
1407
|
"enduser-notification": (0, exports.objectValidator)(__assign({ info: (0, exports.objectValidator)({
|
|
1146
|
-
templateId: exports.
|
|
1147
|
-
}, { emptyOk: true })
|
|
1408
|
+
templateId: exports.mongoIdStringOptional,
|
|
1409
|
+
}, { emptyOk: true }), type: (0, exports.exactMatchValidator)(['enduser-notification']) }, sharedReminderValidators)),
|
|
1148
1410
|
"user-notification": (0, exports.objectValidator)(__assign({ info: (0, exports.objectValidator)({
|
|
1149
|
-
templateId: exports.
|
|
1150
|
-
}, { emptyOk: true })
|
|
1411
|
+
templateId: exports.mongoIdStringOptional,
|
|
1412
|
+
}, { emptyOk: true }), type: (0, exports.exactMatchValidator)(['user-notification']) }, sharedReminderValidators)),
|
|
1151
1413
|
});
|
|
1152
|
-
exports.listOfCalendarEventRemindersValidator = (0, exports.listValidatorEmptyOk)(
|
|
1414
|
+
exports.listOfCalendarEventRemindersValidator = (0, exports.listValidatorEmptyOk)(exports.calendarEventReminderValidator);
|
|
1153
1415
|
exports.cancelConditionsValidator = (0, exports.listOfObjectsValidator)({
|
|
1154
|
-
type: (0, exports.exactMatchValidator)(['formResponse'])
|
|
1416
|
+
type: (0, exports.exactMatchValidator)(['formResponse']),
|
|
1155
1417
|
info: (0, exports.objectValidator)({
|
|
1156
1418
|
automationStepId: exports.mongoIdStringRequired,
|
|
1157
|
-
}, { emptyOk: false })
|
|
1419
|
+
}, { emptyOk: false }),
|
|
1158
1420
|
});
|
|
1421
|
+
exports.cancelConditionsValidatorOptional = (0, exports.listValidatorOptionalOrEmptyOk)((0, exports.objectValidator)({
|
|
1422
|
+
type: (0, exports.exactMatchValidator)(['formResponse']),
|
|
1423
|
+
info: (0, exports.objectValidator)({
|
|
1424
|
+
automationStepId: exports.mongoIdStringRequired,
|
|
1425
|
+
}, { emptyOk: false }),
|
|
1426
|
+
}));
|
|
1159
1427
|
var delayValidation = {
|
|
1160
1428
|
automationStepId: exports.mongoIdStringRequired,
|
|
1161
|
-
delayInMS:
|
|
1162
|
-
delay:
|
|
1163
|
-
unit:
|
|
1164
|
-
cancelConditions:
|
|
1429
|
+
delayInMS: exports.nonNegNumberValidator,
|
|
1430
|
+
delay: exports.nonNegNumberValidator,
|
|
1431
|
+
unit: exports.UnitOfTimeValidator,
|
|
1432
|
+
cancelConditions: exports.cancelConditionsValidatorOptional,
|
|
1165
1433
|
};
|
|
1166
1434
|
exports.automationEventValidator = (0, exports.orValidator)({
|
|
1167
1435
|
formResponse: (0, exports.objectValidator)({
|
|
1168
|
-
type: (0, exports.exactMatchValidator)(['formResponse'])
|
|
1436
|
+
type: (0, exports.exactMatchValidator)(['formResponse']),
|
|
1169
1437
|
info: (0, exports.objectValidator)({
|
|
1170
|
-
automationStepId:
|
|
1171
|
-
}, { emptyOk: false })
|
|
1172
|
-
})
|
|
1438
|
+
automationStepId: exports.mongoIdStringRequired,
|
|
1439
|
+
}, { emptyOk: false }),
|
|
1440
|
+
}),
|
|
1173
1441
|
afterAction: (0, exports.objectValidator)({
|
|
1174
|
-
type: (0, exports.exactMatchValidator)(['afterAction'])
|
|
1175
|
-
info: (0, exports.objectValidator)(delayValidation, { emptyOk: false })
|
|
1176
|
-
})
|
|
1442
|
+
type: (0, exports.exactMatchValidator)(['afterAction']),
|
|
1443
|
+
info: (0, exports.objectValidator)(delayValidation, { emptyOk: false }),
|
|
1444
|
+
}),
|
|
1177
1445
|
formUnsubmitted: (0, exports.objectValidator)({
|
|
1178
|
-
type: (0, exports.exactMatchValidator)(['formUnsubmitted'])
|
|
1179
|
-
info: (0, exports.objectValidator)(__assign(__assign({}, delayValidation), { automationStepId: exports.mongoIdStringRequired }), { emptyOk: false })
|
|
1180
|
-
})
|
|
1446
|
+
type: (0, exports.exactMatchValidator)(['formUnsubmitted']),
|
|
1447
|
+
info: (0, exports.objectValidator)(__assign(__assign({}, delayValidation), { automationStepId: exports.mongoIdStringRequired }), { emptyOk: false }),
|
|
1448
|
+
}),
|
|
1181
1449
|
onJourneyStart: (0, exports.objectValidator)({
|
|
1182
|
-
type: (0, exports.exactMatchValidator)(['onJourneyStart'])
|
|
1183
|
-
info: (0, exports.objectValidator)({}, { emptyOk: true })
|
|
1184
|
-
})
|
|
1450
|
+
type: (0, exports.exactMatchValidator)(['onJourneyStart']),
|
|
1451
|
+
info: (0, exports.objectValidator)({}, { emptyOk: true }),
|
|
1452
|
+
}),
|
|
1185
1453
|
ticketCompleted: (0, exports.objectValidator)({
|
|
1186
|
-
type: (0, exports.exactMatchValidator)(['ticketCompleted'])
|
|
1454
|
+
type: (0, exports.exactMatchValidator)(['ticketCompleted']),
|
|
1187
1455
|
info: (0, exports.objectValidator)({
|
|
1188
1456
|
automationStepId: exports.mongoIdStringRequired,
|
|
1189
|
-
closedForReason:
|
|
1190
|
-
}, { emptyOk: false })
|
|
1191
|
-
})
|
|
1457
|
+
closedForReason: exports.stringValidatorOptional,
|
|
1458
|
+
}, { emptyOk: false }),
|
|
1459
|
+
}),
|
|
1192
1460
|
});
|
|
1193
|
-
exports.automationEventsValidator = (0, exports.listValidatorEmptyOk)(
|
|
1461
|
+
exports.automationEventsValidator = (0, exports.listValidatorEmptyOk)(exports.automationEventValidator);
|
|
1194
1462
|
exports.automationConditionValidator = (0, exports.orValidator)({
|
|
1195
1463
|
atJourneyState: (0, exports.objectValidator)({
|
|
1196
|
-
type: (0, exports.exactMatchValidator)(['atJourneyState'])
|
|
1197
|
-
info: (0, exports.objectValidator)({ state:
|
|
1198
|
-
})
|
|
1464
|
+
type: (0, exports.exactMatchValidator)(['atJourneyState']),
|
|
1465
|
+
info: (0, exports.objectValidator)({ state: exports.stringValidator100, journeyId: exports.mongoIdStringRequired }, { emptyOk: false }),
|
|
1466
|
+
}),
|
|
1199
1467
|
});
|
|
1200
|
-
exports.listOfAutomationConditionsValidator = (0, exports.listValidatorEmptyOk)(
|
|
1468
|
+
exports.listOfAutomationConditionsValidator = (0, exports.listValidatorEmptyOk)(exports.automationConditionValidator);
|
|
1201
1469
|
var _SEND_FORM_CHANNELS = {
|
|
1202
1470
|
Email: '',
|
|
1203
1471
|
SMS: '',
|
|
1204
1472
|
};
|
|
1205
1473
|
exports.SEND_FORM_CHANNELS = Object.keys(_SEND_FORM_CHANNELS);
|
|
1206
1474
|
exports.sendFormChannelValidator = (0, exports.exactMatchValidator)(exports.SEND_FORM_CHANNELS);
|
|
1475
|
+
exports.sendFormChannelValidatorOptional = (0, exports.exactMatchValidatorOptional)(exports.SEND_FORM_CHANNELS);
|
|
1207
1476
|
exports.automationActionValidator = (0, exports.orValidator)({
|
|
1208
1477
|
setEnduserStatus: (0, exports.objectValidator)({
|
|
1209
|
-
type: (0, exports.exactMatchValidator)(['setEnduserStatus'])
|
|
1210
|
-
info: (0, exports.objectValidator)({ status:
|
|
1211
|
-
})
|
|
1478
|
+
type: (0, exports.exactMatchValidator)(['setEnduserStatus']),
|
|
1479
|
+
info: (0, exports.objectValidator)({ status: exports.stringValidator250 }, { emptyOk: false }),
|
|
1480
|
+
}),
|
|
1212
1481
|
sendEmail: (0, exports.objectValidator)({
|
|
1213
|
-
type: (0, exports.exactMatchValidator)(['sendEmail'])
|
|
1214
|
-
info: (0, exports.objectValidator)({ senderId:
|
|
1215
|
-
})
|
|
1482
|
+
type: (0, exports.exactMatchValidator)(['sendEmail']),
|
|
1483
|
+
info: (0, exports.objectValidator)({ senderId: exports.mongoIdStringRequired, templateId: exports.mongoIdStringRequired }, { emptyOk: false }),
|
|
1484
|
+
}),
|
|
1216
1485
|
sendSMS: (0, exports.objectValidator)({
|
|
1217
|
-
type: (0, exports.exactMatchValidator)(['sendSMS'])
|
|
1218
|
-
info: (0, exports.objectValidator)({ senderId:
|
|
1219
|
-
})
|
|
1486
|
+
type: (0, exports.exactMatchValidator)(['sendSMS']),
|
|
1487
|
+
info: (0, exports.objectValidator)({ senderId: exports.mongoIdStringRequired, templateId: exports.mongoIdStringRequired }, { emptyOk: false }),
|
|
1488
|
+
}),
|
|
1220
1489
|
sendForm: (0, exports.objectValidator)({
|
|
1221
|
-
type: (0, exports.exactMatchValidator)(['sendForm'])
|
|
1490
|
+
type: (0, exports.exactMatchValidator)(['sendForm']),
|
|
1222
1491
|
info: (0, exports.objectValidator)({
|
|
1223
|
-
senderId:
|
|
1224
|
-
formId:
|
|
1225
|
-
channel:
|
|
1226
|
-
}, { emptyOk: false })
|
|
1227
|
-
})
|
|
1492
|
+
senderId: exports.mongoIdStringRequired,
|
|
1493
|
+
formId: exports.mongoIdStringRequired,
|
|
1494
|
+
channel: exports.sendFormChannelValidatorOptional,
|
|
1495
|
+
}, { emptyOk: false }),
|
|
1496
|
+
}),
|
|
1228
1497
|
createTicket: (0, exports.objectValidator)({
|
|
1229
|
-
type: (0, exports.exactMatchValidator)(['createTicket'])
|
|
1498
|
+
type: (0, exports.exactMatchValidator)(['createTicket']),
|
|
1230
1499
|
info: (0, exports.objectValidator)({
|
|
1231
|
-
title:
|
|
1500
|
+
title: exports.stringValidatorOptional,
|
|
1232
1501
|
assignmentStrategy: (0, exports.orValidator)({
|
|
1233
1502
|
'care-team-random': (0, exports.objectValidator)({
|
|
1234
|
-
type: (0, exports.exactMatchValidator)(['care-team-random'])
|
|
1235
|
-
info: (0, exports.objectValidator)({}, { emptyOk: true })
|
|
1236
|
-
})
|
|
1237
|
-
})
|
|
1238
|
-
closeReasons:
|
|
1503
|
+
type: (0, exports.exactMatchValidator)(['care-team-random']),
|
|
1504
|
+
info: (0, exports.objectValidator)({}, { emptyOk: true }),
|
|
1505
|
+
})
|
|
1506
|
+
}),
|
|
1507
|
+
closeReasons: exports.listOfStringsValidatorOptionalOrEmptyOk,
|
|
1239
1508
|
defaultAssignee: exports.mongoIdStringRequired,
|
|
1240
|
-
}, { emptyOk: false })
|
|
1241
|
-
})
|
|
1509
|
+
}, { emptyOk: false }),
|
|
1510
|
+
}),
|
|
1242
1511
|
sendWebhook: (0, exports.objectValidator)({
|
|
1243
|
-
type: (0, exports.exactMatchValidator)(['sendWebhook'])
|
|
1244
|
-
info: (0, exports.objectValidator)({ message:
|
|
1245
|
-
})
|
|
1512
|
+
type: (0, exports.exactMatchValidator)(['sendWebhook']),
|
|
1513
|
+
info: (0, exports.objectValidator)({ message: exports.stringValidator5000 }, { emptyOk: false }),
|
|
1514
|
+
}),
|
|
1246
1515
|
});
|
|
1247
1516
|
exports.relatedRecordValidator = (0, exports.objectValidator)({
|
|
1248
|
-
type:
|
|
1249
|
-
id:
|
|
1517
|
+
type: exports.stringValidator100,
|
|
1518
|
+
id: exports.mongoIdStringRequired,
|
|
1250
1519
|
creator: exports.mongoIdStringOptional,
|
|
1251
1520
|
});
|
|
1252
|
-
exports.listOfRelatedRecordsValidator = (0, exports.listValidatorEmptyOk)(
|
|
1521
|
+
exports.listOfRelatedRecordsValidator = (0, exports.listValidatorEmptyOk)(exports.relatedRecordValidator);
|
|
1253
1522
|
exports.searchOptionsValidator = (0, exports.objectValidator)({
|
|
1254
|
-
query:
|
|
1523
|
+
query: exports.stringValidator100,
|
|
1255
1524
|
});
|
|
1256
1525
|
exports.notificationPreferenceValidator = (0, exports.objectValidator)({
|
|
1257
|
-
email:
|
|
1526
|
+
email: exports.booleanValidatorOptional,
|
|
1258
1527
|
});
|
|
1259
|
-
exports.notificationPreferencesValidator = (0, exports.objectAnyFieldsValidator)(
|
|
1528
|
+
exports.notificationPreferencesValidator = (0, exports.objectAnyFieldsValidator)(exports.notificationPreferenceValidator);
|
|
1260
1529
|
exports.FHIRObservationCategoryValidator = (0, exports.exactMatchValidator)(['vital-signs']);
|
|
1261
1530
|
var _FHIR_OBSERVATION_STATUS_CODES = {
|
|
1262
1531
|
"entered-in-error": '',
|
|
@@ -1271,37 +1540,37 @@ var _FHIR_OBSERVATION_STATUS_CODES = {
|
|
|
1271
1540
|
exports.FHIR_OBSERVATION_STATUS_CODES = Object.keys(_FHIR_OBSERVATION_STATUS_CODES);
|
|
1272
1541
|
exports.FHIRObservationStatusCodeValidator = (0, exports.exactMatchValidator)(exports.FHIR_OBSERVATION_STATUS_CODES);
|
|
1273
1542
|
exports.FHIRObservationValueValidator = (0, exports.objectValidator)({
|
|
1274
|
-
unit:
|
|
1275
|
-
value:
|
|
1543
|
+
unit: exports.stringValidator,
|
|
1544
|
+
value: exports.numberValidator,
|
|
1276
1545
|
});
|
|
1277
1546
|
exports.previousFormFieldValidator = (0, exports.orValidator)({
|
|
1278
1547
|
root: (0, exports.objectValidator)({
|
|
1279
|
-
type: (0, exports.exactMatchValidator)(['root'])
|
|
1280
|
-
info: (0, exports.objectValidator)({}, { emptyOk: true })
|
|
1281
|
-
})
|
|
1548
|
+
type: (0, exports.exactMatchValidator)(['root']),
|
|
1549
|
+
info: (0, exports.objectValidator)({}, { emptyOk: true }),
|
|
1550
|
+
}),
|
|
1282
1551
|
"after": (0, exports.objectValidator)({
|
|
1283
|
-
type: (0, exports.exactMatchValidator)(['after'])
|
|
1284
|
-
info: (0, exports.objectValidator)({ fieldId: exports.mongoIdStringRequired }, { emptyOk: false })
|
|
1285
|
-
})
|
|
1552
|
+
type: (0, exports.exactMatchValidator)(['after']),
|
|
1553
|
+
info: (0, exports.objectValidator)({ fieldId: exports.mongoIdStringRequired }, { emptyOk: false }),
|
|
1554
|
+
}),
|
|
1286
1555
|
"previousEquals": (0, exports.objectValidator)({
|
|
1287
|
-
type: (0, exports.exactMatchValidator)(['previousEquals'])
|
|
1556
|
+
type: (0, exports.exactMatchValidator)(['previousEquals']),
|
|
1288
1557
|
info: (0, exports.objectValidator)({
|
|
1289
1558
|
fieldId: exports.mongoIdStringRequired,
|
|
1290
|
-
equals:
|
|
1291
|
-
}, { emptyOk: false })
|
|
1292
|
-
})
|
|
1559
|
+
equals: exports.stringValidator250,
|
|
1560
|
+
}, { emptyOk: false }),
|
|
1561
|
+
}),
|
|
1293
1562
|
});
|
|
1294
|
-
exports.previousFormFieldsValidator = (0, exports.listValidatorEmptyOk)(
|
|
1563
|
+
exports.previousFormFieldsValidator = (0, exports.listValidatorEmptyOk)(exports.previousFormFieldValidator);
|
|
1295
1564
|
exports.portalSettingsValidator = (0, exports.objectValidator)({});
|
|
1296
1565
|
exports.organizationThemeValidator = (0, exports.objectValidator)({
|
|
1297
|
-
logoURL:
|
|
1298
|
-
themeColor:
|
|
1299
|
-
name:
|
|
1300
|
-
subdomain:
|
|
1301
|
-
businessId: exports.
|
|
1302
|
-
faviconURL:
|
|
1303
|
-
customPortalURL:
|
|
1304
|
-
portalSettings:
|
|
1566
|
+
logoURL: exports.stringValidatorOptional,
|
|
1567
|
+
themeColor: exports.stringValidatorOptional,
|
|
1568
|
+
name: exports.stringValidator250,
|
|
1569
|
+
subdomain: exports.stringValidator250,
|
|
1570
|
+
businessId: exports.mongoIdStringRequired,
|
|
1571
|
+
faviconURL: exports.stringValidator250,
|
|
1572
|
+
customPortalURL: exports.stringValidator250,
|
|
1573
|
+
portalSettings: exports.portalSettingsValidator,
|
|
1305
1574
|
});
|
|
1306
1575
|
var _MANAGED_CONTENT_RECORD_TYPES = {
|
|
1307
1576
|
Article: '',
|
|
@@ -1310,94 +1579,97 @@ var _MANAGED_CONTENT_RECORD_TYPES = {
|
|
|
1310
1579
|
};
|
|
1311
1580
|
exports.MANAGED_CONTENT_RECORD_TYPES = Object.keys(_MANAGED_CONTENT_RECORD_TYPES);
|
|
1312
1581
|
exports.managedContentRecordTypeValidator = (0, exports.exactMatchValidator)(exports.MANAGED_CONTENT_RECORD_TYPES);
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1582
|
+
exports.passwordValidator = {
|
|
1583
|
+
getExample: getExampleString,
|
|
1584
|
+
getType: getTypeString,
|
|
1585
|
+
validate: (function (o) { return (0, exports.build_validator)(function (password) {
|
|
1586
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1587
|
+
if (typeof password !== 'string') {
|
|
1588
|
+
throw new Error("Password must be a string");
|
|
1589
|
+
}
|
|
1590
|
+
if (password.length < 8) {
|
|
1591
|
+
throw new Error("Password must be at least 8 characters long");
|
|
1592
|
+
}
|
|
1593
|
+
if (((_b = (_a = password.match(/[a-z]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) < 1 // 1 lowercase
|
|
1594
|
+
|| (((_d = (_c = password.match(/[A-Z]/g)) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) < 1 // 1 uppercase
|
|
1595
|
+
&& ((_f = (_e = password.match(/[0-9]/g)) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) < 1 // 1 number
|
|
1596
|
+
&& ((_h = (_g = password.match(/[^a-zA-Z0-9]/g)) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 1 // 1 special character
|
|
1597
|
+
)) {
|
|
1598
|
+
console.error('bad password regex');
|
|
1599
|
+
throw new Error('Password must included 1 uppercase letter, 1 number, or 1 symbol');
|
|
1600
|
+
}
|
|
1601
|
+
return password;
|
|
1602
|
+
}, __assign(__assign({}, o), { listOf: false, emptyStringOk: false })); }),
|
|
1603
|
+
};
|
|
1332
1604
|
exports.flowchartUIValidator = (0, exports.objectValidator)({
|
|
1333
|
-
x:
|
|
1334
|
-
y:
|
|
1605
|
+
x: exports.numberValidator,
|
|
1606
|
+
y: exports.numberValidator,
|
|
1335
1607
|
}, { emptyOk: true });
|
|
1336
1608
|
exports.integrationAuthenticationsValidator = (0, exports.objectValidator)({
|
|
1337
|
-
type: (0, exports.exactMatchValidator)(['oauth2'])
|
|
1609
|
+
type: (0, exports.exactMatchValidator)(['oauth2']),
|
|
1338
1610
|
info: (0, exports.objectValidator)({
|
|
1339
|
-
access_token:
|
|
1340
|
-
refresh_token:
|
|
1341
|
-
scope:
|
|
1342
|
-
expiry_date:
|
|
1343
|
-
token_type: (0, exports.exactMatchValidator)(['Bearer'])
|
|
1344
|
-
state:
|
|
1345
|
-
email:
|
|
1346
|
-
})
|
|
1611
|
+
access_token: exports.stringValidator250,
|
|
1612
|
+
refresh_token: exports.stringValidator250,
|
|
1613
|
+
scope: exports.stringValidator5000,
|
|
1614
|
+
expiry_date: exports.nonNegNumberValidator,
|
|
1615
|
+
token_type: (0, exports.exactMatchValidator)(['Bearer']),
|
|
1616
|
+
state: exports.stringValidatorOptional,
|
|
1617
|
+
email: exports.emailValidatorOptional,
|
|
1618
|
+
}),
|
|
1347
1619
|
});
|
|
1348
1620
|
exports.formFieldOptionsValidator = (0, exports.objectValidator)({
|
|
1349
|
-
choices:
|
|
1350
|
-
from:
|
|
1351
|
-
to:
|
|
1352
|
-
other:
|
|
1353
|
-
radio:
|
|
1621
|
+
choices: exports.listOfStringsValidatorOptionalOrEmptyOk,
|
|
1622
|
+
from: exports.numberValidatorOptional,
|
|
1623
|
+
to: exports.numberValidatorOptional,
|
|
1624
|
+
other: exports.stringValidatorOptional,
|
|
1625
|
+
radio: exports.booleanValidatorOptional,
|
|
1354
1626
|
});
|
|
1355
1627
|
exports.blockValidator = (0, exports.orValidator)({
|
|
1356
1628
|
h1: (0, exports.objectValidator)({
|
|
1357
|
-
type: (0, exports.exactMatchValidator)(['h1'])
|
|
1629
|
+
type: (0, exports.exactMatchValidator)(['h1']),
|
|
1358
1630
|
info: (0, exports.objectValidator)({
|
|
1359
|
-
text:
|
|
1360
|
-
})
|
|
1361
|
-
})
|
|
1631
|
+
text: exports.stringValidator5000EmptyOkay,
|
|
1632
|
+
}),
|
|
1633
|
+
}),
|
|
1362
1634
|
h2: (0, exports.objectValidator)({
|
|
1363
|
-
type: (0, exports.exactMatchValidator)(['h2'])
|
|
1635
|
+
type: (0, exports.exactMatchValidator)(['h2']),
|
|
1364
1636
|
info: (0, exports.objectValidator)({
|
|
1365
|
-
text:
|
|
1366
|
-
})
|
|
1367
|
-
})
|
|
1637
|
+
text: exports.stringValidator5000EmptyOkay,
|
|
1638
|
+
}),
|
|
1639
|
+
}),
|
|
1368
1640
|
html: (0, exports.objectValidator)({
|
|
1369
|
-
type: (0, exports.exactMatchValidator)(['html'])
|
|
1641
|
+
type: (0, exports.exactMatchValidator)(['html']),
|
|
1370
1642
|
info: (0, exports.objectValidator)({
|
|
1371
|
-
html:
|
|
1372
|
-
})
|
|
1373
|
-
})
|
|
1643
|
+
html: exports.stringValidator25000EmptyOkay,
|
|
1644
|
+
}),
|
|
1645
|
+
}),
|
|
1374
1646
|
image: (0, exports.objectValidator)({
|
|
1375
|
-
type: (0, exports.exactMatchValidator)(['image'])
|
|
1647
|
+
type: (0, exports.exactMatchValidator)(['image']),
|
|
1376
1648
|
info: (0, exports.objectValidator)({
|
|
1377
|
-
link:
|
|
1378
|
-
name:
|
|
1379
|
-
height:
|
|
1380
|
-
width:
|
|
1381
|
-
})
|
|
1382
|
-
})
|
|
1649
|
+
link: exports.stringValidator5000EmptyOkay,
|
|
1650
|
+
name: exports.stringValidatorOptional,
|
|
1651
|
+
height: exports.numberValidatorOptional,
|
|
1652
|
+
width: exports.numberValidatorOptional,
|
|
1653
|
+
}),
|
|
1654
|
+
}),
|
|
1383
1655
|
pdf: (0, exports.objectValidator)({
|
|
1384
|
-
type: (0, exports.exactMatchValidator)(['pdf'])
|
|
1656
|
+
type: (0, exports.exactMatchValidator)(['pdf']),
|
|
1385
1657
|
info: (0, exports.objectValidator)({
|
|
1386
|
-
link:
|
|
1387
|
-
name:
|
|
1388
|
-
height:
|
|
1389
|
-
width:
|
|
1390
|
-
})
|
|
1391
|
-
})
|
|
1658
|
+
link: exports.stringValidator5000EmptyOkay,
|
|
1659
|
+
name: exports.stringValidatorOptional,
|
|
1660
|
+
height: exports.numberValidatorOptional,
|
|
1661
|
+
width: exports.numberValidatorOptional,
|
|
1662
|
+
}),
|
|
1663
|
+
}),
|
|
1392
1664
|
youtube: (0, exports.objectValidator)({
|
|
1393
|
-
type: (0, exports.exactMatchValidator)(['youtube'])
|
|
1665
|
+
type: (0, exports.exactMatchValidator)(['youtube']),
|
|
1394
1666
|
info: (0, exports.objectValidator)({
|
|
1395
|
-
link:
|
|
1396
|
-
name:
|
|
1397
|
-
height:
|
|
1398
|
-
width:
|
|
1399
|
-
})
|
|
1400
|
-
})
|
|
1667
|
+
link: exports.stringValidator5000EmptyOkay,
|
|
1668
|
+
name: exports.stringValidatorOptional,
|
|
1669
|
+
height: exports.numberValidatorOptional,
|
|
1670
|
+
width: exports.numberValidatorOptional,
|
|
1671
|
+
}),
|
|
1672
|
+
}),
|
|
1401
1673
|
});
|
|
1402
1674
|
var _BLOCK_TYPES = {
|
|
1403
1675
|
h1: '',
|
|
@@ -1411,7 +1683,7 @@ exports.BLOCK_TYPES = Object.keys(_BLOCK_TYPES);
|
|
|
1411
1683
|
exports.blockTypeValidator = (0, exports.exactMatchValidator)(exports.BLOCK_TYPES);
|
|
1412
1684
|
var is_block_type = function (type) { return exports.BLOCK_TYPES.includes(type); };
|
|
1413
1685
|
exports.is_block_type = is_block_type;
|
|
1414
|
-
exports.blocksValidator = (0, exports.listValidatorEmptyOk)(
|
|
1686
|
+
exports.blocksValidator = (0, exports.listValidatorEmptyOk)(exports.blockValidator);
|
|
1415
1687
|
var _DATABASE_RECORD_FIELD_TYPES = {
|
|
1416
1688
|
"string-long": '',
|
|
1417
1689
|
number: '',
|
|
@@ -1438,30 +1710,30 @@ exports.is_database_record_field_type = is_database_record_field_type;
|
|
|
1438
1710
|
// })
|
|
1439
1711
|
// structure as above instead if need unique label or additional config based on type
|
|
1440
1712
|
exports.databaseFieldValidator = (0, exports.objectValidator)({
|
|
1441
|
-
type:
|
|
1442
|
-
label:
|
|
1713
|
+
type: exports.databaseRecordFieldTypeValidator,
|
|
1714
|
+
label: exports.stringValidator250,
|
|
1443
1715
|
});
|
|
1444
|
-
exports.databaseFieldsValidator = (0, exports.listValidator)(
|
|
1716
|
+
exports.databaseFieldsValidator = (0, exports.listValidator)(exports.databaseFieldValidator);
|
|
1445
1717
|
exports.databaseRecordValueValidator = (0, exports.orValidator)({
|
|
1446
1718
|
string: (0, exports.objectValidator)({
|
|
1447
|
-
type: (0, exports.exactMatchValidator)(['string'])
|
|
1448
|
-
value:
|
|
1449
|
-
})
|
|
1719
|
+
type: (0, exports.exactMatchValidator)(['string']),
|
|
1720
|
+
value: exports.stringValidator1000,
|
|
1721
|
+
}),
|
|
1450
1722
|
'string-long': (0, exports.objectValidator)({
|
|
1451
|
-
type: (0, exports.exactMatchValidator)(['string-long'])
|
|
1452
|
-
value:
|
|
1453
|
-
})
|
|
1723
|
+
type: (0, exports.exactMatchValidator)(['string-long']),
|
|
1724
|
+
value: exports.stringValidator5000,
|
|
1725
|
+
}),
|
|
1454
1726
|
'number': (0, exports.objectValidator)({
|
|
1455
|
-
type: (0, exports.exactMatchValidator)(['number'])
|
|
1456
|
-
value:
|
|
1457
|
-
})
|
|
1727
|
+
type: (0, exports.exactMatchValidator)(['number']),
|
|
1728
|
+
value: exports.numberValidator,
|
|
1729
|
+
}),
|
|
1458
1730
|
});
|
|
1459
|
-
exports.databaseRecordValuesValidator = (0, exports.listValidator)(
|
|
1731
|
+
exports.databaseRecordValuesValidator = (0, exports.listValidator)(exports.databaseRecordValueValidator);
|
|
1460
1732
|
exports.organizationAccessValidator = (0, exports.objectValidator)({
|
|
1461
|
-
create:
|
|
1462
|
-
update:
|
|
1463
|
-
read:
|
|
1464
|
-
delete:
|
|
1733
|
+
create: exports.booleanValidatorOptional,
|
|
1734
|
+
update: exports.booleanValidatorOptional,
|
|
1735
|
+
read: exports.booleanValidatorOptional,
|
|
1736
|
+
delete: exports.booleanValidatorOptional,
|
|
1465
1737
|
});
|
|
1466
1738
|
var _PORTAL_PAGES = {
|
|
1467
1739
|
"Care Plan": true,
|
|
@@ -1475,33 +1747,33 @@ exports.PORTAL_PAGES = Object.keys(_PORTAL_PAGES);
|
|
|
1475
1747
|
exports.portalPageValidator = (0, exports.exactMatchValidator)(exports.PORTAL_PAGES);
|
|
1476
1748
|
exports.portalBlockValidator = (0, exports.orValidator)({
|
|
1477
1749
|
carePlan: (0, exports.objectValidator)({
|
|
1478
|
-
type: (0, exports.exactMatchValidator)(['carePlan'])
|
|
1479
|
-
info: (0, exports.objectValidator)({}, { emptyOk: true })
|
|
1480
|
-
})
|
|
1750
|
+
type: (0, exports.exactMatchValidator)(['carePlan']),
|
|
1751
|
+
info: (0, exports.objectValidator)({}, { emptyOk: true })
|
|
1752
|
+
}),
|
|
1481
1753
|
education: (0, exports.objectValidator)({
|
|
1482
|
-
type: (0, exports.exactMatchValidator)(['education'])
|
|
1483
|
-
info: (0, exports.objectValidator)({}, { emptyOk: true })
|
|
1484
|
-
})
|
|
1754
|
+
type: (0, exports.exactMatchValidator)(['education']),
|
|
1755
|
+
info: (0, exports.objectValidator)({}, { emptyOk: true })
|
|
1756
|
+
}),
|
|
1485
1757
|
careTeam: (0, exports.objectValidator)({
|
|
1486
|
-
type: (0, exports.exactMatchValidator)(['careTeam'])
|
|
1758
|
+
type: (0, exports.exactMatchValidator)(['careTeam']),
|
|
1487
1759
|
info: (0, exports.objectValidator)({
|
|
1488
|
-
title:
|
|
1760
|
+
title: exports.stringValidator,
|
|
1489
1761
|
// members: listValidatorEmptyOk(
|
|
1490
1762
|
// objectValidator<CareTeamMemberPortalCustomizationInfo>({
|
|
1491
1763
|
// title: stringValidator(),
|
|
1492
1764
|
// role: stringValidator({ isOptional: true }),
|
|
1493
1765
|
// })()
|
|
1494
1766
|
// )()
|
|
1495
|
-
})
|
|
1496
|
-
})
|
|
1767
|
+
})
|
|
1768
|
+
}),
|
|
1497
1769
|
text: (0, exports.objectValidator)({
|
|
1498
|
-
type: (0, exports.exactMatchValidator)(['text'])
|
|
1770
|
+
type: (0, exports.exactMatchValidator)(['text']),
|
|
1499
1771
|
info: (0, exports.objectValidator)({
|
|
1500
|
-
text:
|
|
1501
|
-
})
|
|
1502
|
-
})
|
|
1772
|
+
text: exports.stringValidator5000,
|
|
1773
|
+
})
|
|
1774
|
+
}),
|
|
1503
1775
|
});
|
|
1504
|
-
exports.portalBlocksValidator = (0, exports.listValidatorEmptyOk)(
|
|
1776
|
+
exports.portalBlocksValidator = (0, exports.listValidatorEmptyOk)(exports.portalBlockValidator);
|
|
1505
1777
|
var _PORTAL_BLOCK_TYPES = {
|
|
1506
1778
|
carePlan: '',
|
|
1507
1779
|
careTeam: '',
|
|
@@ -1514,13 +1786,13 @@ exports.enduserTaskForEventValidator = (0, exports.objectValidator)({
|
|
|
1514
1786
|
id: exports.mongoIdStringRequired,
|
|
1515
1787
|
enduserId: exports.mongoIdStringRequired,
|
|
1516
1788
|
});
|
|
1517
|
-
exports.enduserTasksForEventValidator = (0, exports.listValidatorEmptyOk)(
|
|
1789
|
+
exports.enduserTasksForEventValidator = (0, exports.listValidatorEmptyOk)(exports.enduserTaskForEventValidator);
|
|
1518
1790
|
exports.enduserFormResponseForEventValidator = (0, exports.objectValidator)({
|
|
1519
1791
|
enduserId: exports.mongoIdStringRequired,
|
|
1520
1792
|
formId: exports.mongoIdStringRequired,
|
|
1521
|
-
accessCode:
|
|
1793
|
+
accessCode: exports.stringValidator1000,
|
|
1522
1794
|
});
|
|
1523
|
-
exports.enduserFormResponsesForEventValidator = (0, exports.listValidatorEmptyOk)(
|
|
1795
|
+
exports.enduserFormResponsesForEventValidator = (0, exports.listValidatorEmptyOk)(exports.enduserFormResponseForEventValidator);
|
|
1524
1796
|
exports.VALID_STATES = [
|
|
1525
1797
|
"AK",
|
|
1526
1798
|
"AL",
|
|
@@ -1582,21 +1854,21 @@ exports.VALID_STATES = [
|
|
|
1582
1854
|
];
|
|
1583
1855
|
exports.stateValidator = (0, exports.exactMatchValidator)(exports.VALID_STATES);
|
|
1584
1856
|
exports.stateCredentialValidator = (0, exports.objectValidator)({
|
|
1585
|
-
expiresAt:
|
|
1586
|
-
state:
|
|
1857
|
+
expiresAt: exports.dateValidatorOptional,
|
|
1858
|
+
state: exports.stateValidator,
|
|
1587
1859
|
});
|
|
1588
|
-
exports.stateCredentialsValidator = (0, exports.listValidatorEmptyOk)(
|
|
1860
|
+
exports.stateCredentialsValidator = (0, exports.listValidatorEmptyOk)(exports.stateCredentialValidator);
|
|
1589
1861
|
exports.availabilityBlockValidator = (0, exports.objectValidator)({
|
|
1590
|
-
durationInMinutes:
|
|
1591
|
-
startTimeInMS:
|
|
1862
|
+
durationInMinutes: exports.nonNegNumberValidator,
|
|
1863
|
+
startTimeInMS: exports.nonNegNumberValidator,
|
|
1592
1864
|
userId: exports.mongoIdStringRequired,
|
|
1593
1865
|
});
|
|
1594
|
-
exports.availabilityBlocksValidator = (0, exports.listValidatorEmptyOk)(
|
|
1866
|
+
exports.availabilityBlocksValidator = (0, exports.listValidatorEmptyOk)(exports.availabilityBlockValidator);
|
|
1595
1867
|
exports.weeklyAvailabilityValidator = (0, exports.objectValidator)({
|
|
1596
|
-
dayOfWeekStartingSundayIndexedByZero:
|
|
1597
|
-
endTimeInMinutes:
|
|
1598
|
-
startTimeInMinutes:
|
|
1868
|
+
dayOfWeekStartingSundayIndexedByZero: exports.nonNegNumberValidator,
|
|
1869
|
+
endTimeInMinutes: exports.nonNegNumberValidator,
|
|
1870
|
+
startTimeInMinutes: exports.nonNegNumberValidator,
|
|
1599
1871
|
});
|
|
1600
|
-
exports.weeklyAvailabilitiesValidator = (0, exports.listValidatorEmptyOk)(
|
|
1872
|
+
exports.weeklyAvailabilitiesValidator = (0, exports.listValidatorEmptyOk)(exports.weeklyAvailabilityValidator);
|
|
1601
1873
|
exports.timezoneValidator = (0, exports.exactMatchValidator)(Object.keys(types_models_1.TIMEZONES));
|
|
1602
1874
|
//# sourceMappingURL=validation.js.map
|