28 lines
819 B
Python
28 lines
819 B
Python
"""Typed confirmation validation for destructive operations.
|
|
|
|
Ensures the user typed an exact confirmation phrase before proceeding
|
|
with dangerous operations (e.g. production deploys, database migrations).
|
|
|
|
Usage::
|
|
|
|
from devx.utils.confirm import validate_confirmation
|
|
|
|
if not validate_confirmation(user_input, expected="deploy-production"):
|
|
raise SystemExit("Confirmation does not match")
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
def validate_confirmation(confirm: str, expected: str) -> bool:
|
|
"""Check if confirmation text matches the expected phrase.
|
|
|
|
Args:
|
|
confirm: The confirmation text entered by the user.
|
|
expected: The exact phrase that must be matched.
|
|
|
|
Returns:
|
|
True if confirmation matches exactly, False otherwise.
|
|
"""
|
|
return confirm == expected
|