| 9 | |
| 10 | // Validation functions |
| 11 | function validateName(name, folderName) { |
| 12 | const errors = []; |
| 13 | if (!name || typeof name !== "string") { |
| 14 | errors.push("name is required and must be a string"); |
| 15 | return errors; |
| 16 | } |
| 17 | if (name.length < 1 || name.length > 50) { |
| 18 | errors.push("name must be between 1 and 50 characters"); |
| 19 | } |
| 20 | if (!/^[a-z0-9-]+$/.test(name)) { |
| 21 | errors.push("name must contain only lowercase letters, numbers, and hyphens"); |
| 22 | } |
| 23 | if (name !== folderName) { |
| 24 | errors.push(`name "${name}" must match folder name "${folderName}"`); |
| 25 | } |
| 26 | return errors; |
| 27 | } |
| 28 | |
| 29 | function validateDescription(description) { |
| 30 | if (!description || typeof description !== "string") { |