@@ -32,8 +32,10 @@ classes should adhere to.
3232 will validate with. It is assumed to be valid, and providing
3333 an invalid schema can lead to undefined behavior. See
3434 :meth: `IValidator.check_schema ` to validate a schema first.
35- :argument types: Deprecated. Instead, create a custom TypeChecker
36- and extend the validator. See :ref: `validating-types ` for details.
35+ :argument types:
36+ .. deprecated :: 2.7.0
37+ Instead, create a custom type checker and extend the validator. See
38+ :ref: `validating-types ` for details.
3739
3840 If used, this overrides or extends the list of known type when
3941 validating the :validator: `type ` property. Should map strings (type
@@ -50,10 +52,13 @@ classes should adhere to.
5052
5153 .. attribute :: DEFAULT_TYPES
5254
53- Deprecated. Under normal usage, this will be an empty dictionary.
55+ .. deprecated :: 2.7.0
56+ Use of this attribute is deprecated in favour of the the new type
57+ checkers.
5458
55- If set, it provides mappings of JSON types to Python types that will
56- be converted to functions and redefined in this object's TypeChecker
59+ It provides mappings of JSON types to Python types that will
60+ be converted to functions and redefined in this object's type checker
61+ if one is not provided.
5762
5863 .. attribute :: META_SCHEMA
5964
@@ -135,6 +140,27 @@ implementors of validator classes that extend or complement the
135140ones included should adhere to it as well. For more information see
136141:ref: `creating-validators `.
137142
143+ Type Checking
144+ -------------
145+
146+ To handle JSON Schema's :validator: `type ` property, a :class: `IValidator ` uses
147+ an associated :class: `TypeChecker `. The type checker provides an immutable
148+ mapping between names of types and functions that can test if an instance is
149+ of that type. The defaults are suitable for most users - each of the
150+ predefined Validators (Draft3, Draft4) has a :class: `TypeChecker ` that can
151+ correctly handle that draft.
152+
153+ See :ref: `validating-types ` for an example of providing a custom type check.
154+
155+ .. autoclass :: TypeChecker
156+ :members:
157+
158+ .. autoexception :: jsonschema.exceptions.UndefinedTypeCheck
159+
160+ Raised when trying to remove a type check that is not known to this
161+ TypeChecker. Internally this is also raised when calling
162+ :meth: `TypeChecker.is_type `, but is caught and re-raised as a
163+ :class: `jsonschema.exceptions.UnknownType ` exception.
138164
139165.. _validating-types :
140166
@@ -166,9 +192,9 @@ existing :class:`TypeChecker` or create a new one. You may then create a new
166192 class MyInteger (object ):
167193 pass
168194
169- def is_my_int (instance ):
170- return Draft3Validator.TYPE_CHECKER .is_type(instance, " number" ) or \
171- isinstance (instance, MyInteger)
195+ def is_my_int (checker , instance ):
196+ return ( Draft3Validator.TYPE_CHECKER .is_type(instance, " number" ) or
197+ isinstance (instance, MyInteger) )
172198
173199 type_checker = Draft3Validator.TYPE_CHECKER .redefine(" number" , is_my_int)
174200
0 commit comments