UNPKG

tinyagent-ts

Version:

Modern TypeScript framework for building AI agents with pluggable tools and ReAct reasoning

19 lines 617 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.compileValidator = compileValidator; /** * Compile a reusable validator function from a Zod schema. * Throws a formatted error message on validation failure. */ function compileValidator(schema) { return (input) => { const result = schema.safeParse(input); if (result.success) return result.data; const msg = result.error.errors .map(e => `${e.path.join('.')}: ${e.message}`) .join(', '); throw new Error(msg); }; } //# sourceMappingURL=validator.js.map