|
21 | 21 | from bson import SON
|
22 | 22 | from bson.binary import (STANDARD, PYTHON_LEGACY,
|
23 | 23 | JAVA_LEGACY, CSHARP_LEGACY)
|
24 |
| -from bson.codec_options import CodecOptions |
| 24 | +from bson.codec_options import CodecOptions, TypeRegistry |
25 | 25 | from bson.py3compat import abc, integer_types, iteritems, string_type
|
26 | 26 | from bson.raw_bson import RawBSONDocument
|
27 | 27 | from pymongo.auth import MECHANISMS
|
@@ -422,6 +422,14 @@ def validate_document_class(option, value):
|
422 | 422 | return value
|
423 | 423 |
|
424 | 424 |
|
| 425 | +def validate_type_registry(option, value): |
| 426 | + """Validate the type_registry option.""" |
| 427 | + if value is not None and not isinstance(value, TypeRegistry): |
| 428 | + raise TypeError("%s must be an instance of %s" % ( |
| 429 | + option, TypeRegistry)) |
| 430 | + return value |
| 431 | + |
| 432 | + |
425 | 433 | def validate_list(option, value):
|
426 | 434 | """Validates that 'value' is a list."""
|
427 | 435 | if not isinstance(value, list):
|
@@ -576,6 +584,7 @@ def validate_tzinfo(dummy, value):
|
576 | 584 |
|
577 | 585 | KW_VALIDATORS = {
|
578 | 586 | 'document_class': validate_document_class,
|
| 587 | + 'type_registry': validate_type_registry, |
579 | 588 | 'read_preference': validate_read_preference,
|
580 | 589 | 'event_listeners': _validate_event_listeners,
|
581 | 590 | 'tzinfo': validate_tzinfo,
|
|
0 commit comments