//#region ../zql/src/query/validate-input.ts
/**
* Validates input using a StandardSchema validator if provided.
* This is shared validation logic used by both defineQuery and defineMutator.
*
* @param name - The name of the query or mutator (for error messages)
* @param input - The input value to validate
* @param validator - Optional StandardSchema validator
* @param kind - Type of definition ('query' or 'mutator') for error messages
* @returns The validated output (either transformed by validator or input as-is)
* @throws Error if validation fails or if an async validator is used
* @internal
*/
function validateInput(name, input, validator, kind) {
	if (!validator) return input;
	const result = validator["~standard"].validate(input);
	if (result instanceof Promise) throw new Error(`Async validators are not supported. ${titleCase(kind)} name ${name}`);
	if (result.issues) throw new Error(`Validation failed for ${kind} ${name}: ${result.issues.map((issue) => issue.message).join(", ")}`);
	return result.value;
}
function titleCase(kind) {
	return kind.charAt(0).toUpperCase() + kind.slice(1);
}
//#endregion
export { validateInput };

//# sourceMappingURL=validate-input.js.map