@@ -71,30 +71,6 @@ async def decorated_function(request: Request, *args: _P.args, **kwargs: _P.kwar
7171 return decorator
7272
7373
74- def validate_path_project_id (
75- f : Callable [Concatenate [Request , _P ], Coroutine [Any , Any , _T ]],
76- ) -> Callable [Concatenate [Request , _P ], Coroutine [Any , Any , _T ]]:
77- """Decorator for a Sanic handler that validates the project_id path parameter."""
78- _path_project_id_regex = re .compile (r"^[A-Za-z0-9]{26}$" )
79-
80- @wraps (f )
81- async def decorated_function (request : Request , * args : _P .args , ** kwargs : _P .kwargs ) -> _T :
82- project_id = cast (str | None , kwargs .get ("project_id" ))
83- if not project_id :
84- raise errors .ProgrammingError (
85- message = "Could not find 'project_id' in the keyword arguments for the handler in order to validate it."
86- )
87- if not _path_project_id_regex .match (project_id ):
88- raise errors .ValidationError (
89- message = f"The 'project_id' path parameter { project_id } does not match the required "
90- f"regex { _path_project_id_regex } "
91- )
92-
93- return await f (request , * args , ** kwargs )
94-
95- return decorated_function
96-
97-
9874def validate_path_user_id (
9975 f : Callable [Concatenate [Request , _P ], Coroutine [Any , Any , _T ]],
10076) -> Callable [Concatenate [Request , _P ], Coroutine [Any , Any , _T ]]:
0 commit comments