@@ -914,17 +914,20 @@ def _validate_foreign_keys(self, data):
914914
915915 return [error_msg ] if error_msg else []
916916
917- def validate_data (self , data ):
918- """Validate the data matches the metadata.
917+ def _validate_data (self , data , table_name = None ):
918+ """Validate the given data matches the metadata.
919919
920920 Checks the following rules:
921- * all tables of the metadata are present in the data
922921 * every table of the data satisfies its own metadata
923- * all foreign keys belong to a primay key
922+ * if no table_name provided, all tables of the metadata are present in the data
923+ * if no table_name provided, that all foreign keys belong to a primay key
924924
925925 Args:
926926 data (dict):
927927 A dictionary of table names to pd.DataFrames.
928+ table_name (str, optional):
929+ The specific table to validate. If set, only validates the data for the
930+ table. If None, validates the data for all tables. Defaults to None.
928931
929932 Raises:
930933 InvalidDataError:
@@ -938,13 +941,35 @@ def validate_data(self, data):
938941 raise InvalidMetadataError ('Please pass in a dictionary mapping tables to dataframes.' )
939942
940943 errors = []
941- errors += self ._validate_missing_tables (data )
944+ errors += self ._validate_missing_tables (data ) if not table_name else []
942945 errors += self ._validate_all_tables (data )
943- errors += self ._validate_foreign_keys (data )
946+ errors += self ._validate_foreign_keys (data ) if not table_name else []
944947
945948 if errors :
946949 raise InvalidDataError (errors )
947950
951+ def validate_data (self , data ):
952+ """Validate the data matches the metadata.
953+
954+ Checks the following rules:
955+ * every table of the data satisfies its own metadata
956+ * all tables of the metadata are present in the data
957+ * all foreign keys belong to a primay key
958+
959+ Args:
960+ data (dict):
961+ A dictionary of table names to pd.DataFrames.
962+
963+ Raises:
964+ InvalidDataError:
965+ This error is being raised if the data is not matching its sdtype requirements.
966+
967+ Warns:
968+ A warning is being raised if ``datetime_format`` is missing from a column represented
969+ as ``object`` in the dataframe and its sdtype is ``datetime``.
970+ """
971+ self ._validate_data (data )
972+
948973 def add_table (self , table_name ):
949974 """Add a table to the metadata.
950975
0 commit comments