Created
December 6, 2022 19:38
-
-
Save ShahriyarR/25957828aa1ac6485a69945365ac117e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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