-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidators.py
More file actions
42 lines (33 loc) · 1.39 KB
/
validators.py
File metadata and controls
42 lines (33 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from flask import request
class Validate:
def password(self, password: str):
special_chars = ['!', '@', '#', '$', '%', '^', '&', '*']
has_special_char = False
for i in password:
if i in special_chars:
has_special_char = True
break
# if does not contains at least one special character
if not has_special_char:
return (False, "password must contains at least one special character e.g. !, @, #, $, %, ^, &, *")
# if contains at least on special character
if len(password) < 8:
return (False, "password length must be equal to or more than 8")
return True
def storageProvider(self):
"""Validate storage proivders options to store documents in specific selected storage
"""
try:
storage_provider = request.values.getlist("storage_provider")
if not storage_provider:
return None
if "pocketbase" in storage_provider and "backblaze" in storage_provider:
return "both"
elif "pocketbase" in storage_provider:
return "pocketbase"
elif "backblaze" in storage_provider:
return "backblaze"
else:
return None
except Exception as e:
return (False, str(e))