mirror of https://gitlab.com/litecord/litecord.git
enums: move Feature to EasyEnum
- schemas: add validator for guild_features type
This commit is contained in:
parent
2c1c384409
commit
c325543242
|
|
@ -18,12 +18,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
import inspect
|
||||
from typing import List, Any
|
||||
from enum import Enum, IntEnum
|
||||
|
||||
|
||||
class EasyEnum(Enum):
|
||||
"""Wrapper around the enum class for convenience."""
|
||||
|
||||
@classmethod
|
||||
def values(cls):
|
||||
def values(cls) -> List[Any]:
|
||||
"""Return list of values for the given enum."""
|
||||
return [v.value for v in cls.__members__.values()]
|
||||
|
||||
|
||||
|
|
@ -210,7 +214,7 @@ class PremiumType:
|
|||
NONE = None
|
||||
|
||||
|
||||
class Feature(Enum):
|
||||
class Feature(EasyEnum):
|
||||
"""Guild features."""
|
||||
invite_splash = 'INVITE_SPLASH'
|
||||
vip = 'VIP_REGIONS'
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ from .permissions import Permissions
|
|||
from .types import Color
|
||||
from .enums import (
|
||||
ActivityType, StatusType, ExplicitFilter, RelationshipType,
|
||||
MessageNotifications, ChannelType, VerificationLevel
|
||||
MessageNotifications, ChannelType, VerificationLevel, Features
|
||||
)
|
||||
|
||||
from litecord.embed.schemas import EMBED_OBJECT
|
||||
|
|
@ -145,6 +145,9 @@ class LitecordValidator(Validator):
|
|||
def _validate_type_nickname(self, value: str) -> bool:
|
||||
return isinstance(value, str) and (len(value) < 32)
|
||||
|
||||
def _validate_type_guild_feature(self, value: str) -> bool:
|
||||
return value in Features.values()
|
||||
|
||||
|
||||
def validate(reqjson: Union[Dict, List], schema: Dict,
|
||||
raise_err: bool = True) -> Dict:
|
||||
|
|
|
|||
Loading…
Reference in New Issue