@classmethod
def validate_batch(cls, batch, sellable, storable=None):
    """Verifies if the given |batch| is valid for the given |sellable|.

        :param batch: A |storablebatch| that is being validated
        :param sellable: A |sellable| that we should use to validate against the batch
        :param storable: If provided, the corresponding |storable| for the given
            batch, to avoid unecessary queries.
         """
    if not storable:
        product = sellable.product
        storable = product and product.storable or None
    if not batch:
        if not storable or not storable.is_batch:
            return
        raise ValueError('Batch should not be None for %r' % sellable)
    if not storable:
        raise ValueError(
            'Batches should only be used with storables, but %r is not one' %
            sellable)
    if not storable.is_batch:
        raise ValueError('This storable %r does not require a batch' % storable
            )
    if batch.storable != storable:
        raise ValueError('Given batch %r and storable %r are not related' %
            (batch, storable))
