from django.core.exceptions import ValidationError
from django.utils.module_loading import import_string


def validate_list(value):
    if not isinstance(value, list):
        raise ValidationError("%s is not a list." % value)


def validate_importstring(value):
    if value is not None:
        try:
            import_string(value)
        except ImportError as e:
            raise ValidationError("%s can not be imported." % value) from e
