diff options
author | David Robertson <davidr@element.io> | 2022-09-15 18:36:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-15 18:36:02 +0100 |
commit | 742f9f9d78490f7f16bdb607a8f61ca258d520ef (patch) | |
tree | 5994c71ad2302aed93d385fb49d3a2716541baa0 /synapse/rest/client/models.py | |
parent | Add a `MXCUri` class to make working with mxc uri's easier. (#13162) (diff) | |
download | synapse-742f9f9d78490f7f16bdb607a8f61ca258d520ef.tar.xz |
A third batch of Pydantic validation for rest/client/account.py (#13736)
Diffstat (limited to 'synapse/rest/client/models.py')
-rw-r--r-- | synapse/rest/client/models.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/synapse/rest/client/models.py b/synapse/rest/client/models.py index 6278450c70..3d7940b0fc 100644 --- a/synapse/rest/client/models.py +++ b/synapse/rest/client/models.py @@ -36,18 +36,20 @@ class AuthenticationData(RequestBodyModel): type: Optional[StrictStr] = None -class ThreePidRequestTokenBody(RequestBodyModel): - if TYPE_CHECKING: - client_secret: StrictStr - else: - # See also assert_valid_client_secret() - client_secret: constr( - regex="[0-9a-zA-Z.=_-]", # noqa: F722 - min_length=0, - max_length=255, - strict=True, - ) +if TYPE_CHECKING: + ClientSecretStr = StrictStr +else: + # See also assert_valid_client_secret() + ClientSecretStr = constr( + regex="[0-9a-zA-Z.=_-]", # noqa: F722 + min_length=1, + max_length=255, + strict=True, + ) + +class ThreepidRequestTokenBody(RequestBodyModel): + client_secret: ClientSecretStr id_server: Optional[StrictStr] id_access_token: Optional[StrictStr] next_link: Optional[StrictStr] @@ -62,7 +64,7 @@ class ThreePidRequestTokenBody(RequestBodyModel): return token -class EmailRequestTokenBody(ThreePidRequestTokenBody): +class EmailRequestTokenBody(ThreepidRequestTokenBody): email: StrictStr # Canonicalise the email address. The addresses are all stored canonicalised @@ -80,6 +82,6 @@ else: ISO3116_1_Alpha_2 = constr(regex="[A-Z]{2}", strict=True) -class MsisdnRequestTokenBody(ThreePidRequestTokenBody): +class MsisdnRequestTokenBody(ThreepidRequestTokenBody): country: ISO3116_1_Alpha_2 phone_number: StrictStr |