Validates an iterable sequence, checking it against an optional schema.

    The schema should be a list of expected values replaced by functions which will be called to
    with the corresponding value in the input.

    :param iterable value:
        The value to be certified.
    :param tuple(object) types:
        A tuple of types of the expected iterable.
    :param func|None certifier:
        A function to be called on each value in the iterable to check that it is valid.
    :param int|None min_len:
        The minimum acceptable length for the iterable.  If None, the minimum length is not checked.
    :param int|None max_len:
        The maximum acceptable length for the iterable.  If None, the maximum length is not checked.
    :param tuple|None schema:
        The schema against which the value should be checked.
        For single-item tuple make sure to add comma at the end of schema tuple, that is,
        for example: schema=(certify_int(),)
    :param bool required:
        Whether the value can't be `None`. Defaults to True.
    :return:
        The certified iterable.
    :rtype:
        iterable
    :raises CertifierTypeError:
        The type is invalid
    :raises CertifierValueError:
        The valid is invalid.

def certify_iterable(
    value, types, certifier=None, min_len=None, max_len=None, schema=None,
    required=True
):
    """
    Validates an iterable sequence, checking it against an optional schema.

    The schema should be a list of expected values replaced by functions which will be called to
    with the corresponding value in the input.

    :param iterable value:
        The value to be certified.
    :param tuple(object) types:
        A tuple of types of the expected iterable.
    :param func|None certifier:
        A function to be called on each value in the iterable to check that it is valid.
    :param int|None min_len:
        The minimum acceptable length for the iterable.  If None, the minimum length is not checked.
    :param int|None max_len:
        The maximum acceptable length for the iterable.  If None, the maximum length is not checked.
    :param tuple|None schema:
        The schema against which the value should be checked.
        For single-item tuple make sure to add comma at the end of schema tuple, that is,
        for example: schema=(certify_int(),)
    :param bool required:
        Whether the value can't be `None`. Defaults to True.
    :return:
        The certified iterable.
    :rtype:
        iterable
    :raises CertifierTypeError:
        The type is invalid
    :raises CertifierValueError:
        The valid is invalid.
    """
    certify_required(
        value=value,
        required=required,
    )
    certify_params(
        (_certify_int_param, 'max_len', max_len, dict(negative=False, required=False)),
        (_certify_int_param, 'min_len', min_len, dict(negative=False, required=False)),
    )
    # Check the type(s):
    if types and not isinstance(value, types):
        raise CertifierTypeError(
            message="value is not an expected type ({value_type!r})".format(
                value_type=value.__class__.__name__
            ),
            value=value,
            required=required,
        )
    if min_len is not None and len(value) < min_len:
        raise CertifierValueError(
            message="expected at least {expected} elements, "
                    "but set is of length {actual}".format(expected=min_len, actual=len(value)),
            value=value,
            required=required,
        )

    if max_len is not None and len(value) > max_len:
        raise CertifierValueError(
            message=("expected at most {expected} elements, "
                     "but {cls} is of length {actual}").format(
                expected=max_len,
                actual=len(value),
                cls=types,
            ),
            value=value,
            required=required,
        )
    # Apply the certifier to all values:
    if certifier is not None:
        map(certifier, value)
    certify_iterable_schema(
        value=value,
        schema=schema,
        required=required,
    )