@middy/util
Advanced tools
+3
-0
@@ -209,2 +209,5 @@ // Copyright 2017 - 2026 will Farrell, Luciano Mammino, and Middy contributors. | ||
| maximum?: number; | ||
| exclusiveMinimum?: number; | ||
| exclusiveMaximum?: number; | ||
| multipleOf?: number; | ||
| enum?: readonly number[]; | ||
@@ -211,0 +214,0 @@ examples?: readonly number[]; |
+27
-6
@@ -14,4 +14,6 @@ // Copyright 2017 - 2026 will Farrell, Luciano Mammino, and Middy contributors. | ||
| // object schema (validated recursively with the same rules). | ||
| // { type: '<type>' | '<type>?', minimum?, maximum?, minLength?, maxLength?, pattern? } | ||
| // Numeric: `minimum`/`maximum` (number/integer). | ||
| // { type: '<type>' | '<type>?', minimum?, maximum?, exclusiveMinimum?, | ||
| // exclusiveMaximum?, multipleOf?, minLength?, maxLength?, pattern? } | ||
| // Numeric: `minimum`/`maximum` (inclusive), `exclusiveMinimum`/ | ||
| // `exclusiveMaximum` (exclusive), `multipleOf` (number/integer). | ||
| // String: `minLength`/`maxLength` (string length), `pattern` (regex source). | ||
@@ -28,2 +30,6 @@ // { type: 'object' | 'object?', properties?: {...}, additionalProperties?: <rule> } | ||
| // catching typos. | ||
| const name = "util"; | ||
| const pkg = `@middy/${name}`; | ||
| const validateOptionsTypeCheckers = { | ||
@@ -187,2 +193,5 @@ string: (v) => typeof v === "string", | ||
| maximum, | ||
| exclusiveMinimum, | ||
| exclusiveMaximum, | ||
| multipleOf, | ||
| pattern, | ||
@@ -200,3 +209,15 @@ minLength, | ||
| } | ||
| if (pattern !== undefined && !new RegExp(pattern).test(value)) { | ||
| if (exclusiveMinimum !== undefined && value <= exclusiveMinimum) { | ||
| fail(`Option '${path}' must be > ${exclusiveMinimum}`); | ||
| } | ||
| if (exclusiveMaximum !== undefined && value >= exclusiveMaximum) { | ||
| fail(`Option '${path}' must be < ${exclusiveMaximum}`); | ||
| } | ||
| if (multipleOf !== undefined) { | ||
| const quotient = value / multipleOf; | ||
| if (!Number.isFinite(quotient) || Math.floor(quotient) !== quotient) { | ||
| fail(`Option '${path}' must be a multiple of ${multipleOf}`); | ||
| } | ||
| } | ||
| if (pattern !== undefined && !pattern.test(value)) { | ||
| fail(`Option '${path}' must match pattern ${pattern}`); | ||
@@ -305,3 +326,3 @@ } | ||
| throw new Error("Request required when assuming role", { | ||
| cause: { package: "@middy/util" }, | ||
| cause: { package: pkg }, | ||
| }); | ||
@@ -406,3 +427,3 @@ } | ||
| throw new Error("Failed to resolve internal values", { | ||
| cause: { package: "@middy/util", data: errors }, | ||
| cause: { package: pkg, data: errors }, | ||
| }); | ||
@@ -438,3 +459,3 @@ } | ||
| `Invalid cacheExpiry value: ${cacheExpiry}. Must be -1 (infinite), 0 (disabled), or a positive number (ms duration or unix timestamp)`, | ||
| { cause: { package: "@middy/util" } }, | ||
| { cause: { package: pkg } }, | ||
| ); | ||
@@ -441,0 +462,0 @@ } |
+2
-2
| { | ||
| "name": "@middy/util", | ||
| "version": "7.3.3", | ||
| "version": "7.3.4", | ||
| "description": "🛵 The stylish Node.js middleware engine for AWS Lambda (util package)", | ||
@@ -60,3 +60,3 @@ "type": "module", | ||
| "@aws-sdk/client-ssm": "^3.0.0", | ||
| "@middy/core": "7.3.3", | ||
| "@middy/core": "7.3.4", | ||
| "@types/aws-lambda": "^8.0.0", | ||
@@ -63,0 +63,0 @@ "@types/node": "^22.0.0", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
36648
2.16%1000
2.25%