validateGadgetParams
validateGadgetParams(
gadget,params):ValidationResult
Defined in: gadgets/validation.ts:125
Validate gadget parameters using the gadget’s schema.
Convenience wrapper that extracts the schema from a gadget instance. If the gadget has no schema, validation always succeeds with the original parameters.
Parameters
Section titled “Parameters”gadget
Section titled “gadget”Gadget instance with optional parameterSchema
params
Section titled “params”Record<string, unknown>
Raw parameters to validate
Returns
Section titled “Returns”ValidationResult with either validated data or error details
Example
Section titled “Example”import { validateGadgetParams, createGadget } from 'llmist';import { z } from 'zod';
const calculator = createGadget({ description: 'Add numbers', schema: z.object({ a: z.number(), b: z.number().default(0), }), execute: ({ a, b }) => String(a + b),});
const result = validateGadgetParams(calculator, { a: 5 });if (result.success) { console.log(result.data); // { a: 5, b: 0 }}