@spytecgps/lambda-utils 3.0.5 → 3.0.6-rc.0

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.
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var BadRequestError = require('../errors/BadRequestError.js');
6
+
7
+ /**
8
+ * @deprecated
9
+ */
10
+ const validateEvent = (event, schema, validateOptions) => {
11
+ if (!schema) {
12
+ console.warn(`skipping validation`);
13
+ return event;
14
+ }
15
+ const { error, value } = schema.validate(event, {
16
+ allowUnknown: validateOptions?.allowUnknown || true,
17
+ errors: {
18
+ label: 'key',
19
+ wrap: {
20
+ label: false,
21
+ },
22
+ },
23
+ });
24
+ if (error) {
25
+ console.error({ error }, 'Validation error');
26
+ throw error.isJoi ? new BadRequestError.default(error.message) : error;
27
+ }
28
+ return value;
29
+ };
30
+
31
+ exports.default = validateEvent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/lambda-utils",
3
- "version": "3.0.5",
3
+ "version": "3.0.6-rc.0",
4
4
  "description": "Lambda Utils",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",