def ensure_valid_reuse()

in scripts/schema/finalizer.py [0:0]


def ensure_valid_reuse(reused_schema, destination_schema=None):
    """
    Raise if either the reused schema or destination schema have root=true.

    Second param is optional, if testing for a self-nesting (where source=destination).
    """
    if reused_schema['schema_details']['root']:
        msg = "Schema {} has attribute root=true and therefore cannot be reused.".format(
            reused_schema['field_details']['name'])
        raise ValueError(msg)
    elif destination_schema and destination_schema['schema_details']['root']:
        msg = "Schema {} has attribute root=true and therefore cannot have other field sets reused inside it.".format(
            destination_schema['field_details']['name'])
        raise ValueError(msg)