🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
import { type ZodString } from "zod";
/**
* Helper function to add path validation to a string schema
* Validates slash usage and trimming for hierarchical names (e.g., folders, prompts)
*/
export const withFolderPathValidation = (schema: ZodString) =>
schema
.regex(/^[^/]/, "Name cannot start with a slash")
.regex(/^(?!.*\/\/)/, "Name cannot contain consecutive slashes")
.regex(/^.*[^/]$/, "Name cannot end with a slash")
.transform((s) => s.trim())
.refine((s) => s.length > 0, "Name cannot be empty");