summaryrefslogtreecommitdiff
path: root/src/home/config/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/home/config/config.py')
-rw-r--r--src/home/config/config.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/home/config/config.py b/src/home/config/config.py
index e89cc82..d526bb2 100644
--- a/src/home/config/config.py
+++ b/src/home/config/config.py
@@ -2,6 +2,7 @@ import toml
import yaml
import logging
import os
+import pprint
from cerberus import Validator, DocumentError
from typing import Optional, Any, MutableMapping, Union
@@ -120,7 +121,15 @@ class ConfigUnit:
# pprint(self._data)
if not result:
# pprint(v.errors)
- raise DocumentError(f'{self.__class__.__name__}: failed to validate data: {v.errors}')
+ raise DocumentError(f'{self.__class__.__name__}: failed to validate data:\n{pprint.pformat(v.errors)}')
+ try:
+ self.custom_validator(self._data)
+ except Exception as e:
+ raise DocumentError(f'{self.__class__.__name__}: {str(e)}')
+
+ @staticmethod
+ def custom_validator(data):
+ pass
def __getitem__(self, key):
return self._data[key]