def mac_address(value,
                allow_empty = False,
                **kwargs):
    """Validate that ``value`` is a valid MAC address.

    :param value: The value to validate.
    :type value: :class:`str <python:str>` / :obj:`None <python:None>`

    :param allow_empty: If ``True``, returns :obj:`None <python:None>` if
      ``value`` is empty. If ``False``, raises a
      :class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
      if ``value`` is empty. Defaults to ``False``.
    :type allow_empty: :class:`bool <python:bool>`

    :returns: ``value`` / :obj:`None <python:None>`
    :rtype: :class:`str <python:str>` / :obj:`None <python:None>`

    :raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
    :raises CannotCoerceError: if ``value`` is not a valid :class:`str <python:str>`
      or string-like object
    :raises InvalidMACAddressError: if ``value`` is not a valid MAC address or empty with
      ``allow_empty`` set to ``True``

    """
    if not value and not allow_empty:
        raise errors.EmptyValueError('value (%s) was empty' % value)
    elif not value:
        return None

    if not isinstance(value, basestring):
        raise errors.CannotCoerceError('value must be a valid string, '
                                       'was %s' % type(value))

    if '-' in value:
        value = value.replace('-', ':')

    value = value.lower().strip()

    is_valid = MAC_ADDRESS_REGEX.match(value)

    if not is_valid:
        raise errors.InvalidMACAddressError('value (%s) is not a valid MAC '
                                            'address' % value)

    return value
def mac_address ( value , allow_empty = False , ** kwargs ) : if not value and not allow_empty : raise errors . EmptyValueError ( 'value (%s) was empty' % value ) elif not value : return None if not isinstance ( value , basestring ) : raise errors . CannotCoerceError ( 'value must be a valid string, ' 'was %s' % type ( value ) ) if '-' in value : value = value . replace ( '-' , ':' ) value = value . lower ( ) . strip ( ) is_valid = MAC_ADDRESS_REGEX . match ( value ) if not is_valid : raise errors . InvalidMACAddressError ( 'value (%s) is not a valid MAC ' 'address' % value ) return value
Validate that ``value`` is a valid MAC address.

    :param value: The value to validate.
    :type value: :class:`str <python:str>` / :obj:`None <python:None>`

    :param allow_empty: If ``True``, returns :obj:`None <python:None>` if
      ``value`` is empty. If ``False``, raises a
      :class:`EmptyValueError <validator_collection.errors.EmptyValueError>`
      if ``value`` is empty. Defaults to ``False``.
    :type allow_empty: :class:`bool <python:bool>`

    :returns: ``value`` / :obj:`None <python:None>`
    :rtype: :class:`str <python:str>` / :obj:`None <python:None>`

    :raises EmptyValueError: if ``value`` is empty and ``allow_empty`` is ``False``
    :raises CannotCoerceError: if ``value`` is not a valid :class:`str <python:str>`
      or string-like object
    :raises InvalidMACAddressError: if ``value`` is not a valid MAC address or empty with
      ``allow_empty`` set to ``True``