mirror of
https://github.com/Xevion/runnerspace.git
synced 2025-12-06 07:16:13 -06:00
Since Heroku refuses to let me downloda the spaCy model, we're going with this instead. :/
15 lines
459 B
Python
15 lines
459 B
Python
from typing import Optional
|
|
from wtforms.validators import ValidationError
|
|
from better_profanity import profanity
|
|
|
|
|
|
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 profanity.contains_profanity(field.data):
|
|
raise ValidationError(self.message)
|