UNPKG

1.16 kBJavaScriptView Raw
1"use strict";
2/**
3 * @module botbuilder
4 */
5/**
6 * Copyright (c) Microsoft Corporation. All rights reserved.
7 * Licensed under the MIT License.
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10function validateAndFixActivity(activity) {
11 if (typeof activity !== 'object') {
12 throw new Error(`validateAndFixActivity(): invalid request body.`);
13 }
14 if (typeof activity.type !== 'string') {
15 throw new Error(`validateAndFixActivity(): missing activity type.`);
16 }
17 if (typeof activity.timestamp === 'string') {
18 activity.rawTimestamp = activity.timestamp;
19 activity.timestamp = new Date(activity.timestamp);
20 }
21 if (typeof activity.expiration === 'string') {
22 activity.rawExpiration = activity.expiration;
23 activity.expiration = new Date(activity.expiration);
24 }
25 if (typeof activity.localTimestamp === 'string') {
26 activity.rawLocalTimestamp = activity.localTimestamp;
27 activity.localTimestamp = new Date(activity.localTimestamp);
28 }
29 return activity;
30}
31exports.validateAndFixActivity = validateAndFixActivity;
32;
33//# sourceMappingURL=activityValidator.js.map
\No newline at end of file