Created
March 1, 2023 16:07
-
-
Save mikauser001/951e16d3b9858ece62374c901346ac58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import textwrap | |
from django.core.exceptions import ValidationError | |
from profanity_check import predict | |
def check_profanity(value: str): | |
"""Profanity check (Programmed by a 3rd party lib)""" | |
if predict(textwrap.wrap(value)): | |
raise ValidationError( | |
_( | |
'%(value)s contains offensive parts. If this is wrong, please report it. Otherwise just refactor your content' | |
), | |
params={'value': value}, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If this is wrong, please report it, because profanity can't be accurate