UNPKG

botbuilder

Version:

Bot Builder is a framework for building rich bots on virtually any platform.

39 lines 1.45 kB
"use strict"; /** * @module botbuilder */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.validateAndFixActivity = void 0; /** * Validates an [Activity](xref:botbuilder-core.Activity) and formats the timestamp fields. * * @param activity [Activity](xref:botbuilder-core.Activity) to be validated. * @returns The [Activity](xref:botframework-schema.Activity). */ function validateAndFixActivity(activity) { if (typeof activity !== 'object') { throw new Error('validateAndFixActivity(): invalid request body.'); } if (typeof activity.type !== 'string') { throw new Error('validateAndFixActivity(): missing activity type.'); } if (typeof activity.timestamp === 'string') { activity.rawTimestamp = activity.timestamp; activity.timestamp = new Date(activity.timestamp); } if (typeof activity.expiration === 'string') { activity.rawExpiration = activity.expiration; activity.expiration = new Date(activity.expiration); } if (typeof activity.localTimestamp === 'string') { activity.rawLocalTimestamp = activity.localTimestamp; activity.localTimestamp = new Date(activity.localTimestamp); } return activity; } exports.validateAndFixActivity = validateAndFixActivity; //# sourceMappingURL=activityValidator.js.map