admin管理员组文章数量:1134054
A production server is down due to some outdated drivers so I've been upgrading packages to get it working again. I think I'm quite close but eve is giving me some trouble. I have the following schema to validate. Removed some fields for clarity;
survey.py
from . import question
from . import building_data
from . import address
schema = {
'buildingAddress': {
'type': 'dict',
'schema': address.schema,
},
'surveyType': {
'type': 'string',
'allowed': [
"local",
"global",
],
},
'questions': {
'type': 'list',
'schema': {
'type': 'dict',
'schema': question.embedded_schema,
}
},
}
questions.py
import copy
schema = {
'name': {
'type': 'string',
'required': True
},
'type': {
'type': 'string',
'allowed': [
'boolean',
'shortText',
],
'required': True,
},
'group': {
'type': 'string'
},
'title': {
'type': 'string',
'required': True
},
'oldCode': {
'type': 'string'
},
'questionSets': {
'type': 'list',
'schema': {
'type': 'string'
},
},
'min': {
'type': 'number',
'nullable': True,
},
'max': {
'type': 'number',
'nullable': True,
},
'range': {
'type': 'number',
'nullable': True,
'min': 1,
},
'minValue': {
'type': 'string',
},
'maxValue': {
'type': 'string',
},
# single / multiple choice
'choices': {
'type': 'dict',
'propertyschema': {
'type': 'string',
'regex': '\d+'
}
},
}
embedded_schema = copy.deepcopy(schema)
embedded_schema.update(
{
'_id': {
'type': 'objectid',
'data_relation': {
'resource': 'questions',
'field': '_id',
'embeddable': False
}
},
}
)
For whatever reason, a SchemaError(self.schema_validator.errors) exception is raised when making a post call. The error is seemingly from the "questions" field, as the rest of the exception i as follows. Clipped the rest for readability.
{'questions': [{'schema': ['no definitions validate', {'anyof definition 0': [{'schema': [{'_id': ['unknown rule'], '_version': ['unknown rule'], 'choices': ['unknown rule'], 'group': ['unknown rule'], 'maxValue': ['unknown rule'], 'minValue': ['unknown rule'], 'name': ['unknown rule'], 'oldCode': ['unknown rule'], 'questionSets': ['unknown rule'], 'range': ['unknown rule'], 'title': ['unknown rule'], 'type': ["must be of ['string', 'list'] type"]}], 'type': ['null value not allowed']}], 'anyof definition 1': [{'schema': ['no definitions validate', {'anyof definition 0': [{'choices': [{'propertyschema': ['unknown rule']}]}] ...
I've tried several different combinations of eve and cerberus to no luck. I've looked through the repository and Cerberus is not being imported anywhere in the code, so it has to be the eve version of cerberus being used.
I'm currently on eve 1.1.5 and cerberus 1.3.6. Upgraded fron eve 0.7.10 and Cerberus 0.9.2
I would appreciate any help/suggestions.
本文标签:
版权声明:本文标题:validation - python-eve Cerberus keeps throwing "uknown rule" error for embedded dictionary? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736775908a1952334.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论