AnPv2/Python/Utils/Check.py

27 lines
701 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from typing import Any, Self
from Utils.Patterns import RE
class Check:
@staticmethod
def is_string(value:Any|None) -> bool:
return isinstance(value, str)
@classmethod
def is_key(cls:type[Self], value:Any|None) -> bool:
return cls.is_string(value) and RE.KEY.match(value) is not None
@staticmethod
def is_array(value:Any|None) -> bool:
return isinstance(value, (list, tuple))
@staticmethod
def is_dictionary(value:Any|None) -> bool:
return isinstance(value, dict)
@staticmethod
def is_integer(value:Any|None) -> bool:
return isinstance(value, int)