@@ -49,7 +49,7 @@ def enforce(self, rule, do_raise=False, exc=None):
4949
5050class ValidateMixin :
5151 min_length = 8
52- not_contain : str = string .whitespace
52+ not_contain : list [ str ] = [ string .whitespace ]
5353 must_contain : list [str ] = None # [digits, ascii_uppercase, punctuation]
5454 regex : str = None
5555
@@ -59,8 +59,11 @@ def validate(self, value):
5959 error = "Value is required"
6060 elif self .min_length and len (value ) < self .min_length :
6161 error = f"Value must be at least { self .min_length } characters long"
62- elif self .not_contain and set (self .not_contain ) & set (value ):
63- error = f"Value must not contain { self .not_contain } "
62+ elif self .not_contain :
63+ for not_contain in self .not_contain :
64+ if set (not_contain ) & set (value ):
65+ error = f"Value must not contain { self .not_contain } "
66+ break
6467 elif self .must_contain :
6568 for required in self .must_contain :
6669 if not set (required ) & set (value ):
@@ -73,6 +76,8 @@ def validate(self, value):
7376 exc .message = error
7477 raise exc
7578
79+
80+ class ValidateSecretMixin (ValidateMixin ):
7681 def validate_secret (self , kwargs : dict ):
7782 if "secret" in kwargs :
7883 self .validate (kwargs ["secret" ])
@@ -102,7 +107,9 @@ def _get_app_endpoint(req):
102107
103108
104109class UserController (
105- controllers .BaseResourceControllerPaginated , EnforceMixin , ValidateMixin
110+ controllers .BaseResourceControllerPaginated ,
111+ EnforceMixin ,
112+ ValidateSecretMixin ,
106113):
107114 __resource__ = resources .ResourceByModelWithCustomProps (
108115 models .User ,
0 commit comments