Files
runnerspace/validators.py
Xevion 73d9fd5454 Replace profanity-filter with better-profanity
Since Heroku refuses to let me downloda the spaCy model, we're going
with this instead. :/
2022-03-30 15:57:47 -05:00

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)