Al-HUWAITI Shell
Al-huwaiti


Server : LiteSpeed
System : Linux in-mum-web1949.main-hosting.eu 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64
User : u595547767 ( 595547767)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /opt/alt/python311/lib/python3.11/site-packages/validators/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python311/lib/python3.11/site-packages/validators/mac_address.py
"""MAC Address."""

# standard
import re

# local
from .utils import validator


@validator
def mac_address(value: str, /):
    """Return whether or not given value is a valid MAC address.

    This validator is based on [WTForms MacAddress validator][1].

    [1]: https://github.com/wtforms/wtforms/blob/master/src/wtforms/validators.py#L482

    Examples:
        >>> mac_address('01:23:45:67:ab:CD')
        True
        >>> mac_address('00:00:00:00:00')
        ValidationError(func=mac_address, args={'value': '00:00:00:00:00'})

    Args:
        value:
            MAC address string to validate.

    Returns:
        (Literal[True]): If `value` is a valid MAC address.
        (ValidationError): If `value` is an invalid MAC address.
    """
    return re.match(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$", value) if value else False

Al-HUWAITI Shell