MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / validateName

Function validateName

web/src/app/orgs/new/page.tsx:34–54  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

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

Callers 2

handleNameChangeFunction · 0.85
handleSubmitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected