def validate(table_path: str, entry: str, *, validator=None) -> bool:
"""
Validate a CDV entry by ID directly from file.
Always reloads the file from disk to avoid stale data.
"""
path = _resolve_path(table_path)
table = _read_table(path)
if not table:
gw.warn("No table loaded — rejecting validation request.")
return False
record = table.get(entry)
if not record:
return False
if validator:
try:
return bool(validator(**record))
except Exception as e:
gw.error(f"validator failed: {e}")
return False
return True