

def validate(instance, schema, cls=None, *args, **kwargs):
    '\n    Validate an instance under the given schema.\n\n        >>> validate([2, 3, 4], {"maxItems" : 2})\n        Traceback (most recent call last):\n            ...\n        ValidationError: [2, 3, 4] is too long\n\n    :func:`validate` will first verify that the provided schema is itself\n    valid, since not doing so can lead to less obvious error messages and fail\n    in less obvious or consistent ways. If you know you have a valid schema\n    already or don\'t care, you might prefer using the\n    :meth:`~IValidator.validate` method directly on a specific validator\n    (e.g. :meth:`Draft4Validator.validate`).\n\n\n    :argument instance: the instance to validate\n    :argument schema: the schema to validate with\n    :argument cls: an :class:`IValidator` class that will be used to validate\n                   the instance.\n\n    If the ``cls`` argument is not provided, two things will happen in\n    accordance with the specification. First, if the schema has a\n    :validator:`$schema` property containing a known meta-schema [#]_ then the\n    proper validator will be used.  The specification recommends that all\n    schemas contain :validator:`$schema` properties for this reason. If no\n    :validator:`$schema` property is found, the default validator class is\n    :class:`Draft4Validator`.\n\n    Any other provided positional and keyword arguments will be passed on when\n    instantiating the ``cls``.\n\n    :raises:\n        :exc:`ValidationError` if the instance is invalid\n\n        :exc:`SchemaError` if the schema itself is invalid\n\n    .. rubric:: Footnotes\n    .. [#] known by a validator registered with :func:`validates`\n    '
    if (cls is None):
        cls = validator_for(schema)
    cls.check_schema(schema)
    cls(schema, *args, **kwargs).validate(instance)

dataset/ETHPy150Open danielyule/hearthbreaker/jsonschema/validators.py validate/original