def validate(self, ontology): """ Validate the type subfields and fields against the ontology. Throws errors when issue encountered args: - ontology: ontology object to check assets against """ fields = self.get_all_asset_fields() invalid_subfields = ontology.check_subfields(fields) invalid_fields = ontology.check_fields(fields) assert len( invalid_subfields ) == 0, "Undefined subfields (define them or change them): {}".format( str(invalid_subfields)) assert len( invalid_fields ) == 0, "Undefined fields (define them or change them): {}".format( str(invalid_fields)) print("[INFO]\tNo representation errors!")
def validate_without_errors(self, ontology): """ Validate the subfields and fields against the ontology. Only prints errors seen, but runs through everything args: - ontology: the ontology object to validate the assets against """ fields = self.get_all_asset_fields() invalid_subfields = ontology.check_subfields(fields) invalid_fields = ontology.check_fields(fields) has_errors = False if len(invalid_subfields) > 0: has_errors = True print('Undefined subfields (define them or change them):') for subfield in invalid_subfields: print('\t{}'.format(subfield)) if len(invalid_fields) > 0: has_errors = True print('Undefined fields (define them or change them):') for field in invalid_fields: print('\t{}'.format(field)) if has_errors == False: print("No representation errors!")