← 教程列表
coding

Layer 1: Entry Point Validation

📅 2026/6/12 16:30:02⏱ 约 5 分钟阅读👁 8 阅读

**Purpose:** Reject obviously invalid input at API boundary ```typescript function createProject(name: string, workingDirectory: string) { if (!workingDirectory || workingDirectory.trim() === '') { throw new Error('workingDirectory cannot be empty'); } if (!existsSync(workingDirectory)) { throw new Error(`workingDirectory does not exist: ${workingDirectory}`); } if (!statSync(workingDirectory).isDirectory()) { throw new Error(`workingDirectory is not a directory: ${workingDirectory}`); } // ... proceed } ```

← 返回教程列表 AI8899 · 内容仅供学习参考