From 395b07d3ab01236601a7834f18d430d144cb3435 Mon Sep 17 00:00:00 2001 From: lguntde <62409257+lguntde@users.noreply.github.com> Date: Fri, 27 Aug 2021 16:35:04 +0200 Subject: [PATCH] Update column.py --- pandas_schema/column.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandas_schema/column.py b/pandas_schema/column.py index 199b883..6c64858 100644 --- a/pandas_schema/column.py +++ b/pandas_schema/column.py @@ -24,4 +24,9 @@ def validate(self, series: pd.Series) -> typing.List[ValidationWarning]: :param series: A pandas Series to validate :return: An iterable of ValidationError instances generated by the validation """ - return [error for validation in self.validations for error in validation.get_errors(series, self)] + + # skip validation if column contains no validation objects. Used for columns that require no validation but must be present in DataFrame + if self.validations == []: + return [] + else: + return [error for validation in self.validations for error in validation.get_errors(series, self)]