File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -43,10 +43,17 @@ def _io_descriptor_converter(it: t.Any) -> type[IODescriptor]:
4343 return ensure_io_descriptor (it )
4444
4545
46+ def _starts_with_slash (
47+ instance : t .Any , attribute : attrs .Attribute [str ], value : str
48+ ) -> None :
49+ if not value .startswith ("/" ):
50+ raise ValueError (f"{ attribute .name } must start with a leading slash" )
51+
52+
4653@attrs .define
4754class APIMethod (t .Generic [P , R ]):
4855 func : t .Callable [t .Concatenate [t .Any , P ], R ]
49- route : str = attrs .field ()
56+ route : str = attrs .field (validator = _starts_with_slash )
5057 name : str = attrs .field (init = False )
5158 input_spec : type [IODescriptor ] = attrs .field (converter = _io_descriptor_converter )
5259 output_spec : type [IODescriptor ] = attrs .field (converter = _io_descriptor_converter )
You can’t perform that action at this time.
0 commit comments