Created
December 6, 2022 18:03
-
-
Save ShahriyarR/80e54801fcbee00c1e98491da6461bd3 to your computer and use it in GitHub Desktop.
This file contains 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
from pydantic import BaseModel, validator | |
class InvalidDBCredentialsModel(BaseModel): | |
comment: str | |
password: Password | |
uri: DBUri | |
port: DBPort | |
host: DBHost | |
@validator("password") | |
def password_length_check(cls, v): | |
passwd = v.get_secret() | |
if len(passwd) > 7: | |
v.add_secret(passwd) | |
return v | |
raise ValueError("Password length should be more than 7") | |
class Config: | |
arbitrary_types_allowed = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment