(name: string)
| 26 | * @returns The validated name with invalid characters removed, trimmed, and collapsed whitespace |
| 27 | */ |
| 28 | export function validateName(name: string): string { |
| 29 | return name |
| 30 | .replace(/[^a-zA-Z0-9_\s]/g, '') // Remove invalid characters |
| 31 | .replace(/\s+/g, ' ') // Collapse multiple spaces into single spaces |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Checks if a name contains invalid characters |
no test coverage detected