MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / validate_project_name

Function validate_project_name

server/utils/validation.py:34–54  ·  view source on GitHub ↗

Validate and return *name*, or raise ``HTTPException(400)``. Suitable for REST endpoint handlers where FastAPI will convert the exception into an HTTP 400 response automatically. Args: name: Project name to validate. Returns: The validated project name (unchanged).

(name: str)

Source from the content-addressed store, hash-verified

32
33
34def validate_project_name(name: str) -> str:
35 """Validate and return *name*, or raise ``HTTPException(400)``.
36
37 Suitable for REST endpoint handlers where FastAPI will convert the
38 exception into an HTTP 400 response automatically.
39
40 Args:
41 name: Project name to validate.
42
43 Returns:
44 The validated project name (unchanged).
45
46 Raises:
47 HTTPException: If *name* is invalid.
48 """
49 if not _PROJECT_NAME_RE.match(name):
50 raise HTTPException(
51 status_code=400,
52 detail="Invalid project name. Use only letters, numbers, hyphens, and underscores (1-50 chars)."
53 )
54 return name

Callers 1

project_websocketFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected