Skip to content

validators

django_spire.contrib.ordering.validators

OrderingMixinValidator

Source code in django_spire/contrib/ordering/validators.py
def __init__(
    self,
    destination_objects: QuerySet[Model],
    position: int,
    obj: Model,
    origin_objects: QuerySet[Model],
):
    self._destination_objects = destination_objects
    self._position = position
    self._origin_objects = origin_objects
    self._obj = obj

    self._errors: list[OrderingMixinException] = []

errors property

Returns list of OrderingMixinException errors.

validate

Validates that the destination and origin and insertion objects and position are valid. Returns tuple of validity and applicable error messages.

Source code in django_spire/contrib/ordering/validators.py
def validate(self) -> bool:
    """
    Validates that the destination and origin and insertion objects and position are valid.
    Returns tuple of validity and applicable error messages.
    """
    self._validate_position()

    return False if self._errors else True