Upload files to "database"

Add Database to initial commit
This commit is contained in:
chris 2025-03-10 23:12:52 +00:00
parent 9727d18345
commit 265b661571
2 changed files with 12 additions and 0 deletions

BIN
database/__init__.py Normal file

Binary file not shown.

12
database/fields.py Normal file
View File

@ -0,0 +1,12 @@
import re
from mongoengine import StringField
class RegexField(StringField):
def __init__(self, regex, *args, **kwargs):
super().__init__(*args, **kwargs)
self.regex = re.compile(regex)
def validate(self, value, clean=True):
if not self.regex.fullmatch(value):
self.error('The given string does not match the regex for this field')