summaryrefslogtreecommitdiff
path: root/kvmd/validators/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/validators/__init__.py')
-rw-r--r--kvmd/validators/__init__.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/kvmd/validators/__init__.py b/kvmd/validators/__init__.py
index 39ff60aa..aa997ab9 100644
--- a/kvmd/validators/__init__.py
+++ b/kvmd/validators/__init__.py
@@ -99,3 +99,11 @@ def check_any(arg: Any, name: str, validators: list[Callable[[Any], Any]]) -> An
except Exception:
pass
raise_error(arg, name)
+
+
+# =====
+def filter_printable(arg: str, replace: str, limit: int) -> str:
+ return "".join(
+ (ch if ch.isprintable() else replace)
+ for ch in arg[:limit]
+ )