mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-08-31 23:33:25 +00:00
Validate Range to disallow min > max
This commit is contained in:
parent
c61e407b50
commit
fd9c244f48
@ -310,6 +310,9 @@ def _make_range_transformer(
|
|||||||
min: Optional[Union[int, float]] = None,
|
min: Optional[Union[int, float]] = None,
|
||||||
max: Optional[Union[int, float]] = None,
|
max: Optional[Union[int, float]] = None,
|
||||||
) -> Type[Transformer]:
|
) -> Type[Transformer]:
|
||||||
|
if min and max and min > max:
|
||||||
|
raise TypeError('minimum cannot be larger than maximum')
|
||||||
|
|
||||||
ns = {
|
ns = {
|
||||||
'type': classmethod(lambda _: opt_type),
|
'type': classmethod(lambda _: opt_type),
|
||||||
'min_value': classmethod(lambda _: min),
|
'min_value': classmethod(lambda _: min),
|
||||||
|
@ -1081,6 +1081,9 @@ else:
|
|||||||
self.min: Optional[Union[int, float]] = min
|
self.min: Optional[Union[int, float]] = min
|
||||||
self.max: Optional[Union[int, float]] = max
|
self.max: Optional[Union[int, float]] = max
|
||||||
|
|
||||||
|
if min and max and min > max:
|
||||||
|
raise TypeError('minimum cannot be larger than maximum')
|
||||||
|
|
||||||
async def convert(self, ctx: Context[BotT], value: str) -> Union[int, float]:
|
async def convert(self, ctx: Context[BotT], value: str) -> Union[int, float]:
|
||||||
count = converted = self.annotation(value)
|
count = converted = self.annotation(value)
|
||||||
if self.annotation is str:
|
if self.annotation is str:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user