Skip to content

Instantly share code, notes, and snippets.

@ShahriyarR
Created December 6, 2022 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShahriyarR/25957828aa1ac6485a69945365ac117e to your computer and use it in GitHub Desktop.
Save ShahriyarR/25957828aa1ac6485a69945365ac117e to your computer and use it in GitHub Desktop.
import icontract
from readonce import ReadOnce
def validate_password_length(password: str) -> bool:
return len(password) > 7
class Password(ReadOnce):
@icontract.ensure(lambda self: len(self) == 1, "Secret is missing")
@icontract.require(
lambda password: validate_password_length(password),
"Password length should be more than 7",
)
def __init__(self, password: str) -> None:
super().__init__()
self.add_secret(password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment