about summary refs log tree commit diff
path: root/quality_control/average.py
diff options
context:
space:
mode:
Diffstat (limited to 'quality_control/average.py')
-rw-r--r--quality_control/average.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/quality_control/average.py b/quality_control/average.py
index 2907b9c..9ca16a9 100644
--- a/quality_control/average.py
+++ b/quality_control/average.py
@@ -1,6 +1,8 @@
 """Contain logic for checking average files"""
 import re
+from typing import Union
 
+from .errors import InvalidValue
 from .errors import InvalidCellValue
 
 def valid_value(val):
@@ -11,3 +13,13 @@ def valid_value(val):
         f"Invalid value '{val}'. "
         "Expected string representing a number with exactly three decimal "
         "places.")
+
+def invalid_value(line_number: int, column_number: int, val: str) -> Union[
+        InvalidValue, None]:
+    if re.search(r"^[0-9]+\.[0-9]{3}$", val):
+        return None
+    return InvalidValue(
+        line_number, column_number, val, (
+            f"Invalid value '{val}'. "
+            "Expected string representing a number with exactly three decimal "
+            "places."))