(name: string)
| 32 | } | null>(null) |
| 33 | |
| 34 | const validateName = (name: string) => { |
| 35 | if (!name.trim()) { |
| 36 | return 'Organization name is required' |
| 37 | } |
| 38 | |
| 39 | if (name.length < 3) { |
| 40 | return 'Organization name must be at least 3 characters long' |
| 41 | } |
| 42 | |
| 43 | if (name.length > 50) { |
| 44 | return 'Organization name must be no more than 50 characters long' |
| 45 | } |
| 46 | |
| 47 | // Allow alphanumeric characters, spaces, hyphens, and underscores (no periods) |
| 48 | const validNameRegex = /^[a-zA-Z0-9\s\-_]+$/ |
| 49 | if (!validNameRegex.test(name)) { |
| 50 | return 'Organization name can only contain letters, numbers, spaces, hyphens, and underscores' |
| 51 | } |
| 52 | |
| 53 | return '' |
| 54 | } |
| 55 | |
| 56 | const handleNameChange = (e: React.ChangeEvent<HTMLInputElement>) => { |
| 57 | const newName = e.target.value |
no outgoing calls
no test coverage detected