summary refs log tree commit diff
path: root/synapse/rest/client/models.py
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-09-15 18:36:02 +0100
committerGitHub <noreply@github.com>2022-09-15 18:36:02 +0100
commit742f9f9d78490f7f16bdb607a8f61ca258d520ef (patch)
tree5994c71ad2302aed93d385fb49d3a2716541baa0 /synapse/rest/client/models.py
parentAdd a `MXCUri` class to make working with mxc uri's easier. (#13162) (diff)
downloadsynapse-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.py28
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