Skip to content

Instantly share code, notes, and snippets.

@zetafish
Created February 20, 2018 23:36
Show Gist options
  • Save zetafish/06f76a7cc435ff085288f2504426dda7 to your computer and use it in GitHub Desktop.
Save zetafish/06f76a7cc435ff085288f2504426dda7 to your computer and use it in GitHub Desktop.
def validate_placeholder_refs(tree):
allowed = set([k for (k, v) in tree['template-set.json']['placeholders'].items()])
def check_refs(placeholder):
for k, v in placeholder.items():
if not k in allowed:
raise Invalid('no-such-placeholder', path=[k])
return placeholder
schema = Schema({
Match(REGEX_WIDTH_HEIGHT): {
'template.json': {
'placeholderExceptions': check_refs
}
}
}, extra=ALLOW_EXTRA)
return schema(tree)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment