Data Validation Patterns
Normalize Input
Raw text usually needs trimming and case normalization before comparison or storage.
Normalize Input
normalize.py
def normalize_name(raw):
trimmed = raw.strip()
return trimmed.lower()
raw_name =
normalized = normalize_name(raw_name)
print(f"name={normalized}")
def normalize_name(raw):
trimmed = raw.strip()
return trimmed.lower()
raw_name =
normalized = normalize_name(raw_name)
print(f"name={normalized}")
normalization
Normalization converts different user input spellings into a stable internal value.