UNPKG

voyageai

Version:

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fvoyage-ai%2Ftypescript-sdk) [![npm shield](

29 lines (28 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.maybeSkipValidation = void 0; function maybeSkipValidation(schema) { return Object.assign(Object.assign({}, schema), { json: transformAndMaybeSkipValidation(schema.json), parse: transformAndMaybeSkipValidation(schema.parse) }); } exports.maybeSkipValidation = maybeSkipValidation; function transformAndMaybeSkipValidation(transform) { return (value, opts) => { const transformed = transform(value, opts); const { skipValidation = false } = opts !== null && opts !== void 0 ? opts : {}; if (!transformed.ok && skipValidation) { // eslint-disable-next-line no-console console.warn([ "Failed to validate.", ...transformed.errors.map((error) => " - " + (error.path.length > 0 ? `${error.path.join(".")}: ${error.message}` : error.message)), ].join("\n")); return { ok: true, value: value, }; } else { return transformed; } }; }