Reputation: 1217
I have the following piece in a Cerberus 1.3.2 schema (that I'm storing as a YAML file):
members:
dependencies:
res_type: gsuite_group
type: dict
keysrules:
allowed:
- gsuite
- csod
schema: gsuite_group_schema
As the rules I'm using for members
are reused in other parts of the schema, I've tried isolating them into their own rule set:
rules_set_registry.add('gsuite_group_ruleset', {
'dependencies': {'res_type': 'gsuite_group'},
'type': 'dict',
'keysrules': {'allowed': ['gsuite', 'csod']},
'schema': 'gsuite_group_schema'}
)
I then change the members
bit into:
members: gsuite_group_ruleset
Doing all of this and calling validator.validate()
results in the following exception:
File "C:\Users\goncalo.lourenco\.virtualenvs\User_Sync-Zf6-tVvH\lib\site-packages\cerberus\validator.py", line 1440, in __validate_schema_mapping
allow_unknown = self.schema[field].get('allow_unknown', self.allow_unknown)
AttributeError: 'str' object has no attribute 'get'
Any ideas as to why this may be happening?
Upvotes: 0
Views: 166
Reputation: 3968
You're using a rules set as constraint to the schema
rule, but it requires a full schema of which the top level keys are key references, not keys.
Upvotes: 1