File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -1030,6 +1030,7 @@ def test_custom_validator(self):
1030
1030
Validator = validators .create (
1031
1031
meta_schema = {"id" : "meta schema id" },
1032
1032
version = "12" ,
1033
+ id_of = lambda s : s .get ("id" , "" ),
1033
1034
)
1034
1035
schema = {"$schema" : "meta schema id" }
1035
1036
self .assertIs (
Original file line number Diff line number Diff line change @@ -52,8 +52,9 @@ def validates(version):
52
52
53
53
def _validates (cls ):
54
54
validators [version ] = cls
55
- if u"id" in cls .META_SCHEMA :
56
- meta_schemas [cls .META_SCHEMA [u"id" ]] = cls
55
+ meta_schema_id = cls .ID_OF (cls .META_SCHEMA )
56
+ if meta_schema_id :
57
+ meta_schemas [meta_schema_id ] = cls
57
58
return cls
58
59
return _validates
59
60
@@ -204,6 +205,7 @@ class Validator(object):
204
205
VALIDATORS = dict (validators )
205
206
META_SCHEMA = dict (meta_schema )
206
207
TYPE_CHECKER = type_checker
208
+ ID_OF = staticmethod (id_of )
207
209
208
210
_DEFAULT_TYPES = dict (default_types )
209
211
You can’t perform that action at this time.
0 commit comments