Compare commits

...

2 Commits

Author SHA1 Message Date
871b455d5e Fix merge conflict 2025-02-13 03:10:28 +05:30
b15cfdfa99 Cleaner code for config validation 2025-02-13 02:48:01 +05:30

View File

@ -1,6 +1,22 @@
import re
from datetime import datetime
def _is_int(value):
"""Check if a value is a valid integer."""
try:
int(value)
return True
except (ValueError, TypeError):
return False
def _is_date(value):
"""Check if a value is a valid date in YYYY-MM-DD format."""
try:
datetime.strptime(value, "%Y-%m-%d")
return True
except (ValueError, TypeError):
return False
def _validate_number(attrib, attrib_name):
"""Validate number-specific attributes."""
if attrib.min and not _is_int(attrib.min):
@ -51,22 +67,6 @@ def _validate_select(attrib, attrib_name):
return False
return True
def _is_int(value):
"""Check if a value is a valid integer."""
try:
int(value)
return True
except (ValueError, TypeError):
return False
def _is_date(value):
"""Check if a value is a valid date in YYYY-MM-DD format."""
try:
datetime.strptime(value, "%Y-%m-%d")
return True
except (ValueError, TypeError):
return False
# Validate the configuration file to ensure all attributes are properly defined.
def validate_config(item_attributes):
for attrib_name, attrib in item_attributes.items():