Add local Windows Server inventory collection and validation; include core package
This commit is contained in:
10
samsara/core/validation.py
Normal file
10
samsara/core/validation.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import re
|
||||
|
||||
def validate_hostname(value):
|
||||
value = value.strip().rstrip(".")
|
||||
if len(value) > 253 or not value or any(
|
||||
not re.fullmatch(r"[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?", label)
|
||||
for label in value.split(".")
|
||||
):
|
||||
raise ValueError("Enter a hostname or FQDN using letters, digits, hyphens and dots (no URLs or commands).")
|
||||
return value.lower()
|
||||
Reference in New Issue
Block a user