def create(<EOL>meta_schema,<EOL>validators=(),<EOL>version=None,<EOL>default_types=None,<EOL>type_checker=None,<EOL>id_of=_id_of,<EOL>):
if default_types is not None:<EOL><INDENT>if type_checker is not None:<EOL><INDENT>raise TypeError(<EOL>"<STR_LIT>",<EOL>)<EOL><DEDENT>_created_with_default_types = True<EOL>warn(<EOL>(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>),<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:2>,<EOL>)<EOL>type_checker = _types.TypeChecker(<EOL>type_checkers=_generate_legacy_type_checks(default_types),<EOL>)<EOL><DEDENT>else:<EOL><INDENT>default_types = _DEPRECATED_DEFAULT_TYPES<EOL>if type_checker is None:<EOL><INDENT>_created_with_default_types = False<EOL>type_checker = _TYPE_CHECKER_FOR_DEPRECATED_DEFAULT_TYPES<EOL><DEDENT>elif type_checker is _TYPE_CHECKER_FOR_DEPRECATED_DEFAULT_TYPES:<EOL><INDENT>_created_with_default_types = False<EOL><DEDENT>else:<EOL><INDENT>_created_with_default_types = None<EOL><DEDENT><DEDENT>@add_metaclass(_DefaultTypesDeprecatingMetaClass)<EOL>class Validator(object):<EOL><INDENT>VALIDATORS = dict(validators)<EOL>META_SCHEMA = dict(meta_schema)<EOL>TYPE_CHECKER = type_checker<EOL>ID_OF = staticmethod(id_of)<EOL>DEFAULT_TYPES = property(_DEFAULT_TYPES)<EOL>_DEFAULT_TYPES = dict(default_types)<EOL>_CREATED_WITH_DEFAULT_TYPES = _created_with_default_types<EOL>def __init__(<EOL>self,<EOL>schema,<EOL>types=(),<EOL>resolver=None,<EOL>format_checker=None,<EOL>):<EOL><INDENT>if types:<EOL><INDENT>warn(<EOL>(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>),<EOL>DeprecationWarning,<EOL>stacklevel=<NUM_LIT:2>,<EOL>)<EOL>self.TYPE_CHECKER = self.TYPE_CHECKER.redefine_many(<EOL>_generate_legacy_type_checks(types),<EOL>)<EOL><DEDENT>if resolver is None:<EOL><INDENT>resolver = RefResolver.from_schema(schema, id_of=id_of)<EOL><DEDENT>self.resolver = resolver<EOL>self.format_checker = format_checker<EOL>self.schema = schema<EOL><DEDENT>@classmethod<EOL>def check_schema(cls, schema):<EOL><INDENT>for error in cls(cls.META_SCHEMA).iter_errors(schema):<EOL><INDENT>raise exceptions.SchemaError.create_from(error)<EOL><DEDENT><DEDENT>def iter_errors(self, instance, _schema=None):<EOL><INDENT>if _schema is None:<EOL><INDENT>_schema = self.schema<EOL><DEDENT>if _schema is True:<EOL><INDENT>return<EOL><DEDENT>elif _schema is False:<EOL><INDENT>yield exceptions.ValidationError(<EOL>"<STR_LIT>" % (instance,),<EOL>validator=None,<EOL>validator_value=None,<EOL>instance=instance,<EOL>schema=_schema,<EOL>)<EOL>return<EOL><DEDENT>scope = id_of(_schema)<EOL>if scope:<EOL><INDENT>self.resolver.push_scope(scope)<EOL><DEDENT>try:<EOL><INDENT>ref = _schema.get(u"<STR_LIT>")<EOL>if ref is not None:<EOL><INDENT>validators = [(u"<STR_LIT>", ref)]<EOL><DEDENT>else:<EOL><INDENT>validators = iteritems(_schema)<EOL><DEDENT>for k, v in validators:<EOL><INDENT>validator = self.VALIDATORS.get(k)<EOL>if validator is None:<EOL><INDENT>continue<EOL><DEDENT>errors = validator(self, v, instance, _schema) or ()<EOL>for error in errors:<EOL><INDENT>error._set(<EOL>validator=k,<EOL>validator_value=v,<EOL>instance=instance,<EOL>schema=_schema,<EOL>)<EOL>if k != u"<STR_LIT>":<EOL><INDENT>error.schema_path.appendleft(k)<EOL><DEDENT>yield error<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>if scope:<EOL><INDENT>self.resolver.pop_scope()<EOL><DEDENT><DEDENT><DEDENT>def descend(self, instance, schema, path=None, schema_path=None):<EOL><INDENT>for error in self.iter_errors(instance, schema):<EOL><INDENT>if path is not None:<EOL><INDENT>error.path.appendleft(path)<EOL><DEDENT>if schema_path is not None:<EOL><INDENT>error.schema_path.appendleft(schema_path)<EOL><DEDENT>yield error<EOL><DEDENT><DEDENT>def validate(self, *args, **kwargs):<EOL><INDENT>for error in self.iter_errors(*args, **kwargs):<EOL><INDENT>raise error<EOL><DEDENT><DEDENT>def is_type(self, instance, type):<EOL><INDENT>try:<EOL><INDENT>return self.TYPE_CHECKER.is_type(instance, type)<EOL><DEDENT>except exceptions.UndefinedTypeCheck:<EOL><INDENT>raise exceptions.UnknownType(type, instance, self.schema)<EOL><DEDENT><DEDENT>def is_valid(self, instance, _schema=None):<EOL><INDENT>error = next(self.iter_errors(instance, _schema), None)<EOL>return error is None<EOL><DEDENT><DEDENT>if version is not None:<EOL><INDENT>Validator = validates(version)(Validator)<EOL>Validator.__name__ = version.title().replace("<STR_LIT:U+0020>", "<STR_LIT>") + "<STR_LIT>"<EOL><DEDENT>return Validator<EOL>
Create a new validator class.

Arguments:

    meta_schema (collections.Mapping):

        the meta schema for the new validator class

    validators (collections.Mapping):

        a mapping from names to callables, where each callable will
        validate the schema property with the given name.

        Each callable should take 4 arguments:

            1. a validator instance,
            2. the value of the property being validated within the
               instance
            3. the instance
            4. the schema

    version (str):

        an identifier for the version that this validator class will
        validate. If provided, the returned validator class will have its
        ``__name__`` set to include the version, and also will have
        `jsonschema.validators.validates` automatically called for the
        given version.

    type_checker (jsonschema.TypeChecker):

        a type checker, used when applying the :validator:`type` validator.

        If unprovided, a `jsonschema.TypeChecker` will be created with
        a set of default types typical of JSON Schema drafts.

    default_types (collections.Mapping):

        .. deprecated:: 3.0.0

            Please use the type_checker argument instead.

        If set, it provides mappings of JSON types to Python types that
        will be converted to functions and redefined in this object's
        `jsonschema.TypeChecker`.

    id_of (callable):

        A function that given a schema, returns its ID.

Returns:

    a new `jsonschema.IValidator` class