mirror of
https://github.com/Xevion/runnerspace.git
synced 2025-12-06 13:16:20 -06:00
17 lines
474 B
Python
17 lines
474 B
Python
from typing import Optional
|
|
from profanity_filter import ProfanityFilter
|
|
from wtforms.validators import ValidationError
|
|
|
|
pf = ProfanityFilter()
|
|
|
|
|
|
class NoProfanity(object):
|
|
def __init__(self, message: Optional[str] = None):
|
|
if not message:
|
|
message = 'Profanity is not acceptable on Runnerspace'
|
|
self.message = message
|
|
|
|
def __call__(self, form, field):
|
|
if pf.is_profane(field.data):
|
|
raise ValidationError(self.message)
|