UUID 128-bit validator

def validate_uuid(value):
    """ UUID 128-bit validator """

    if value and not isinstance(value, UUID):
        try:
            return UUID(str(value), version=4)
        except (AttributeError, ValueError):
            raise ValidationError('not a valid UUID')
    return value