MCPcopy
hub / github.com/middyjs/middy / validateOptions

Function validateOptions

packages/util/index.js:317–338  ·  view source on GitHub ↗
(packageName, schema, options = {})

Source from the content-addressed store, hash-verified

315 Object.hasOwn(schema, "additionalProperties"));
316
317export const validateOptions = (packageName, schema, options = {}) => {
318 const fail = (message) => {
319 throw new TypeError(message, { cause: { package: packageName } });
320 };
321 try {
322 if (isJsonSchemaForm(schema)) {
323 checkRule(schema, options, "", fail);
324 } else {
325 checkSchemaObject(schema, options, "", fail);
326 }
327 } catch (e) {
328 // Re-wrap an internal malformed-schema `SchemaError` so callers still see
329 // the documented `TypeError` + `cause.package`; mismatch errors already
330 // carry that shape and pass through untouched.
331 // Stryker disable next-line ConditionalExpression: forcing this true is equivalent; the only non-SchemaError reaching here is a `fail()` TypeError that already carries cause.package, so re-wrapping it via `fail(e.message)` produces an identical message + cause.
332 if (e instanceof SchemaError) {
333 fail(e.message);
334 }
335 throw e;
336 }
337 return options;
338};
339
340export const createPrefetchClient = (options) => {
341 const { awsClientOptions } = options;

Calls 4

isJsonSchemaFormFunction · 0.85
checkRuleFunction · 0.85
checkSchemaObjectFunction · 0.85
failFunction · 0.85

Tested by

no test coverage detected