I am trying to create a schema for documents that have dependencies that reference the fields above in the document. For instance:
document = {
'packages': {
'some-package': {'version': 1}
},
'build-steps': {
'needs-some-package': {'foo': 'bar'},
'other-thing': {'funky': 'stuff'}
}
}
What I'm facing right now is the forced dependency between build-steps.needs-some-package and package.some-package. Whenever assembly steps contain "needs-some-package", packages should contain "some-package".
When "needs-some-package" is not, "some-package" is not required. Therefore, this document must also be verified.
other_document = {
'packages': {
'other-package': {'version': 1}
},
'build-steps': {
'other-thing': {'funky': 'stuff'}
}
}
A dependency scheme in what seems like a suitable place,
schema = {
'packages': {
'type': 'dict',
'valueschema': {
'type': 'dict'
}
},
'build-steps': {
'type': 'dict',
'schema': {
'needs-some-package': {
'type': 'dict',
'dependencies': 'packages.some-package'
},
'other-thing': {
'type': 'dict'
}
}
}
}
, , Cerberus "" " ". ? - ?