Upload files to "database"
Add Database to initial commit
This commit is contained in:
parent
9727d18345
commit
265b661571
BIN
database/__init__.py
Normal file
BIN
database/__init__.py
Normal file
Binary file not shown.
12
database/fields.py
Normal file
12
database/fields.py
Normal 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')
|
||||||
Loading…
Reference in New Issue
Block a user