Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def formatter(self, value):
db.auth_user.username.requires = (
HAS_NO_DOTS(),
IS_NOT_IN_DB(db, db.auth_user.username),
IS_NOT_EMOJI(db.auth_user.username,f"Username cannot contain emojis")
)
db.auth_user.registration_id.requires = IS_NOT_IN_DB(db, db.auth_user.registration_id)
db.auth_user.email.requires = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"IS_UPPER",
"IS_URL",
"IS_JSON",
"IS_NOT_EMOJI",
]


Expand Down Expand Up @@ -157,6 +158,19 @@ def validator_caller(func, value, record_id=None):
raise ValidationError(error)
return value

class IS_NOT_EMOJI(Validator):
"""
"""
def __init__(self,expression, error_message="Contains Emojis"):

self.expression = expression
self.error_message = error_message
def validate(self, value, record_id=None):
emoji_pattern = re.compile(r'[\U0001F600-\U0001F64F\U0001F300-\U0001F5FF\U0001F680-\U0001F6FF\U0001F700-\U0001F77F\U0001F780-\U0001F7FF\U0001F800-\U0001F8FF\U0001F900-\U0001F9FF\U0001FA00-\U0001FA6F\U0001FA70-\U0001FAFF]')

if emoji_pattern.search(value):
raise ValidationError(self.translator(self.error_message))
return value

class IS_MATCH(Validator):
"""
Expand Down Expand Up @@ -202,7 +216,7 @@ def __init__(
extract=False,
is_unicode=False,
):

if strict or not search:
if not expression.startswith("^"):
expression = "^(%s)" % expression
Expand Down